- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
对不起我的英语,我是 android 的新手并创建应用程序。一切正常,但我有一个非常小的问题是,在抽屉导航中,当我单击项目时,只是抽屉导航被关闭,这没有错误,logcat 上没有任何错误真的我不知道,但我猜 mybe 从布局。我的布局:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/container"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
tools:context=".MyPayamak"
android:layout_height="match_parent"
android:orientation="vertical">
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="@null"
android:background="#ffffff"
android:dividerHeight="10sp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
</ListView>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/tt"/>
<ProgressBar
android:layout_width="45dp"
android:layout_height="45dp"
android:layout_gravity="center"
android:id="@+id/progressBar"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@drawable/bar"
android:orientation="vertical">
<!-- Side navigation drawer UI -->
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="کاربر میهمان"
android:textColor="#3D3D3D"
android:background="#ffffff"
android:layout_gravity="center"
android:gravity="center"
android:padding="15dp"
android:id="@+id/ShowFakenameOfUser"/>
<ImageView
android:layout_marginTop="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@drawable/usericon"/>
<ListView
android:id="@+id/navList"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:divider="@null"
android:dividerHeight="10dp"
android:layout_marginTop="20dp"
android:paddingLeft="20dp"
android:paddingRight="20dp"/>
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
还有一件事,我的抽屉导航代码在所有 Activity 中都是相同的并且工作正常但是 2 个 Activity 有这个问题使用这个布局。
在我的 oncreate 中有这段代码:
mDrawerList = (ListView)findViewById(R.id.navList);
mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
mActivityTitle = getTitle().toString();
mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("ورود")) {
Intent it = new Intent(List_Payamak_ha.this, loginUser.class);
startActivity(it);
}else if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("ثبت نام")){
Intent it = new Intent(List_Payamak_ha.this, RegisterUser.class);
startActivity(it);
}else if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("کاربران فعال")) {
Intent it = new Intent(List_Payamak_ha.this, ActiveUsers.class);
startActivity(it);
}else if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("کاربران برتر")) {
Intent it = new Intent(List_Payamak_ha.this, TopUsers.class);
startActivity(it);
}else if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("درباره نرم افزار")) {
Intent it = new Intent(List_Payamak_ha.this, AboutPage.class);
startActivity(it);
}else if (parent.getItemAtPosition(position).toString().equalsIgnoreCase("خروج")) {
int pid = android.os.Process.myPid();
android.os.Process.killProcess(pid);
finish();
System.exit(0);
}
}
});
addDrawerItems();
setupDrawer();
完整代码:
private void addDrawerItems() {
String[] osArray = getResources().getStringArray(R.array.SlideMenu);
mAdapterCopy = new MenuSideAdapterItem(this,
android.R.layout.simple_list_item_1,
R.id.textViewMenuSide,
osArray);
mDrawerList.setAdapter(mAdapterCopy);
}
private void setupDrawer() {
;
mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout,
R.string.drawer_open, R.string.drawer_close) {
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View view) {
super.onDrawerOpened(view);
getSupportActionBar().setTitle("منو");
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
super.onDrawerClosed(view);
getSupportActionBar().setTitle(mActivityTitle);
invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
}
};
mDrawerToggle.setDrawerIndicatorEnabled(true);
mDrawerLayout.setDrawerListener(mDrawerToggle);
}
@Override
protected void onPostCreate(Bundle savedInstanceState) {
super.onPostCreate(savedInstanceState);
mDrawerToggle.syncState();
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
mDrawerToggle.onConfigurationChanged(newConfig);
}
private class MenuSideAdapterItem extends ArrayAdapter<String> {
public MenuSideAdapterItem(Context context, int resource, int textViewResourceId, String[] objects) {
super(context, resource, textViewResourceId, objects);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View Row = inflater.inflate(R.layout.menu_item,parent,false);
String[] items = getResources().getStringArray(R.array.SlideMenu);
ImageView IconView = (ImageView) Row.findViewById(R.id.imageViewMenuSide);
TextView textMenuSide = (TextView) Row.findViewById(R.id.textViewMenuSide);
textMenuSide.setTypeface(Typeface.createFromAsset(getAssets(), "fonts/Far_TitrDF.ttf"));
textMenuSide.setText(items[position]);
if (items[position].equalsIgnoreCase("ورود")){
IconView.setImageResource(R.drawable.loginicon);
}else if (items[position].equalsIgnoreCase("ثبت نام")){
IconView.setImageResource(R.drawable.registericoon);
}else if (items[position].equalsIgnoreCase("کاربران فعال")){
IconView.setImageResource(R.drawable.activeuser);
}else if (items[position].equalsIgnoreCase("کاربران برتر")){
IconView.setImageResource(R.drawable.topuser);
}else if (items[position].equalsIgnoreCase("درباره نرم افزار")){
IconView.setImageResource(R.drawable.about);
}else if (items[position].equalsIgnoreCase("خروج")){
IconView.setImageResource(R.drawable.exit);
}
return Row;
}
}
最佳答案
问题来自另一个 fragment ,用于在屏幕底部显示图像,当我点击抽屉时 fragment 位于顶部抽屉实际上是我点击了 fragment 所以我从来没有点击过按钮因为我替换了 fragment
使用 RelativeLayout
解决我的问题。
关于android - ListView 项目在抽屉导航中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29590485/
今天有小伙伴给我留言问到,try{...}catch(){...}是什么意思?它用来干什么? 简单的说 他们是用来捕获异常的 下面我们通过一个例子来详细讲解下
我正在努力提高网站的可访问性,但我不知道如何在页脚中标记社交媒体链接列表。这些链接指向我在 facecook、twitter 等上的帐户。我不想用 role="navigation" 标记这些链接,因
说现在是 6 点,我有一个 Timer 并在 10 点安排了一个 TimerTask。之后,System DateTime 被其他服务(例如 ntp)调整为 9 点钟。我仍然希望我的 TimerTas
就目前而言,这个问题不适合我们的问答形式。我们希望答案得到事实、引用资料或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我就废话不多说了,大家还是直接看代码吧~ ? 1
Maven系列1 1.什么是Maven? Maven是一个项目管理工具,它包含了一个对象模型。一组标准集合,一个依赖管理系统。和用来运行定义在生命周期阶段中插件目标和逻辑。 核心功能 Mav
我是一名优秀的程序员,十分优秀!