我是android开发的初学者,我正在创建一个简单的web应用程序,我有这个包含20个字符串/条目的菜单/抽屉,但是我不能向上滑动。在Android Studio,我使用抽屉活动,这些是我唯一使用的文件,我没有改变其他任何东西。
package com.example.psalms;
import android.os.Bundle;
import android.view.View;
import android.view.Menu;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import com.google.android.material.navigation.NavigationView;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
private AppBarConfiguration mAppBarConfiguration;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
DrawerLayout drawer = findViewById(R.id.drawer_layout);
NavigationView navigationView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
mAppBarConfiguration = new AppBarConfiguration.Builder(
R.id.nav_home, R.id.nav_gallery, R.id.nav_slideshow)
.setDrawerLayout(drawer)
.build();
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
NavigationUI.setupActionBarWithNavController(this, navController, mAppBarConfiguration);
NavigationUI.setupWithNavController(navigationView, navController);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
public boolean onSupportNavigateUp() {
NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
return NavigationUI.navigateUp(navController, mAppBarConfiguration)
|| super.onSupportNavigateUp();
}
}
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:showIn="navigation_view">
<group android:checkableBehavior="single">
<item
android:id="@+id/nav_home"
android:icon="@drawable/ic_menu_camera"
android:title="@string/menu_home" />
<item
android:id="@+id/nav_gallery"
android:icon="@drawable/ic_menu_gallery"
android:title="@string/menu_gallery" />
<item
android:id="@+id/nav_slideshow"
android:icon="@drawable/ic_menu_slideshow"
android:title="@string/menu_slideshow" />
<item
android:title="@string/home" />
<item
android:title="@string/ermninia" />
<item
android:title="@string/psalmos1" />
<item
android:title="@string/psalmos2" />
<item
android:title="@string/psalmos3" />
<item
android:title="@string/psalmos4" />
<item
android:title="@string/psalmos5" />
<item
android:title="@string/psalmos6" />
<item
android:title="@string/psalmos7" />
<item
android:title="@string/psalmos8" />
<item
android:title="@string/psalmos9" />
<item
android:title="@string/psalmos10" />
<item
android:title="@string/psalmos11" />
<item
android:title="@string/psalmos12" />
<item
android:title="@string/psalmos13" />
<item
android:title="@string/psalmos14" />
<item
android:title="@string/psalmos15" />
<item
android:title="@string/psalmos16" />
<item
android:title="@string/psalmos17" />
<item
android:title="@string/psalmos18" />
<item
android:title="@string/psalmos19" />
<item
android:title="@string/psalmos20" />
</group>
</menu>
<resources>
<string name="app_name">Psalms</string>
<string name="navigation_drawer_open">Open navigation drawer</string>
<string name="navigation_drawer_close">Close navigation drawer</string>
<string name="nav_header_title">Android Studio</string>
<string name="nav_header_subtitle">android.studio@android.com</string>
<string name="nav_header_desc">Navigation header</string>
<string name="action_settings">Settings</string>
<string name="menu_home">Home</string>
<string name="menu_gallery">Gallery</string>
<string name="menu_slideshow">Slideshow</string>
<string name="home_second">Home Second</string>
<string name="home">Αρχική</string>
<string name="ermninia">Ερμηνεία των Ψαλμών</string>
<string name="psalmos1">Ψαλμός 1</string>
<string name="psalmos2">Ψαλμός 2</string>
<string name="psalmos3">Ψαλμός 3</string>
<string name="psalmos4">Ψαλμός 4</string>
<string name="psalmos5">Ψαλμός 5</string>
<string name="psalmos6">Ψαλμός 6</string>
<string name="psalmos7">Ψαλμός 7</string>
<string name="psalmos8">Ψαλμός 8</string>
<string name="psalmos9">Ψαλμός 9</string>
<string name="psalmos10">Ψαλμός 10</string>
<string name="psalmos11">Ψαλμός 11</string>
<string name="psalmos12">Ψαλμός 12</string>
<string name="psalmos13">Ψαλμός 13</string>
<string name="psalmos14">Ψαλμός 14</string>
<string name="psalmos15">Ψαλμός 15</string>
<string name="psalmos16">Ψαλμός 16</string>
<string name="psalmos17">Ψαλμός 17</string>
<string name="psalmos18">Ψαλμός 18</string>
<string name="psalmos19">Ψαλμός 19</string>
<string name="psalmos20">Ψαλμός 20</string>
</resources>
这是我的事件日志
27/3/2020
5:32 μμ Gradle sync started
5:33 μμ Gradle sync finished in 47 s 503 ms
5:33 μμ Android Studio and Gradle are using different locations for the JDK.
Android Studio: C:\Program Files\Android\Android Studio\jre
Gradle: C:\Program Files\Java\jdk1.8.0_91
Using different JDK locations might cause Gradle to spawn multiple daemons
when executing tasks for Android Studio and other external processes.
More info...
Select a JDK from the File System
Do not show this warning again
5:33 μμ * daemon not running; starting now at tcp:5037
5:33 μμ * daemon started successfully
5:41 μμ Executing tasks: [:app:assembleDebug] in project C:\Users\giorgis\Downloads\android\Psalms
5:42 μμ Gradle build finished in 34 s 905 ms
5:42 μμ Install successfully finished in 5 s 275 ms.
5:49 μμ Executing tasks: [:app:assembleDebug] in project C:\Users\giorgis\Downloads\android\Psalms
5:49 μμ Gradle build finished in 8 s 834 ms
5:49 μμ Install successfully finished in 5 s 96 ms.
6:46 μμ Executing tasks: [:app:assembleDebug] in project C:\Users\giorgis\Downloads\android\Psalms
6:46 μμ Gradle build finished in 9 s 206 ms
6:46 μμ Install successfully finished in 4 s 400 ms.
6:47 μμ Executing tasks: [:app:assembleDebug] in project C:\Users\giorgis\Downloads\android\Psalms
6:47 μμ Gradle build finished in 6 s 416 ms
6:47 μμ Install successfully finished in 3 s 944 ms.
6:50 μμ Gradle sync started
6:50 μμ Android Studio and Gradle are using different locations for the JDK.
Android Studio: C:\Program Files\Android\Android Studio\jre
Gradle: C:\Program Files\Java\jdk1.8.0_91
Using different JDK locations might cause Gradle to spawn multiple daemons
when executing tasks for Android Studio and other external processes.
More info...
Select a JDK from the File System
Do not show this warning again
6:50 μμ Gradle sync finished in 8 s 638 ms
确保您正在使用新的依赖项
implementation 'androidx.navigation:navigation-fragment:2.2.1'
implementation 'androidx.navigation:navigation-ui:2.2.1'
但您应该为添加的每个新项目创建片段
二等 三等
我正在为一个CS项目做一个游戏,其中一个要求是只有一个扫描仪为人类输入。如果我创建一个抽象类“Player”,它有一个扫描器对象,并创建两个扩展“Player”的“人类”类,它们是各自有自己的扫描器,还是共享“Player”扫描器?另外,当我结束游戏时如何关闭扫描仪?
我是android新手。我想实现一个由项目列表组成的导航抽屉,单击它会打开一个新活动。基本上是所有活动的导航抽屉。当我从导航抽屉中选择一个项目时,特定的活动就会打开。导航抽屉代码是通过执行空活动来实现的。我想在所有活动中实现导航抽屉功能,这些活动被视为空活动,这些活动已经有了一些功能,导航抽屉功能也可以工作。请帮帮我。 这是activity_header档案 这是我的主要活动 这是头活动java代
输出为: 输入字符串: WEWEW 输入模式搜索: 线程“main”java.util.NoSuchelementException:在java.util.scanner.nextline(scanner.java:1585) 在org.test.regtest.readline(regtest.java:39) 在org.test.regtest.main(regtest.java:22)
我只想创建一个导航抽屉活动。当我右击应用程序时
当我右击应用程序时,在此处输入图像描述 当我尝试按照上述步骤创建名为“HomeActivity”的导航抽屉活动时。它只是在菜单目录和AndroidManifest中的“.HomeActivity”中创建一个xml文件。xml文件(给出错误)。但是家庭活动。java和activity_主页。xml和其他片段和导航活动未创建。 我已附上我的AndroidManifest。xml代码。注意:我目前使用的