我有一个TabHost,
选项卡A会连接到A活动,
A活动的布局有一个编辑文本框、按钮和一个列表视图。
列表视图是从BaseAdapter自定义的,其中包括一个TextView,没有按钮或图片等。
当我进入程序时,可以单击列表视图项目,
它将连接到B子活动。
但是当我点击返回键(返回到A活动)时,
列表视图的项目无法工作,必须向上或向下拖动,
该项目才能被正确地单击。
我已经搜索了一些资料。
我尝试添加了
android:focusable="false"
android:focusableInTouchMode="false"
android:clickable="false"
or
descendantFocusability="blocksDescendants"
在我的列表视图中,我使用了LinearLayout或者TextView。
但是存在一个问题。
如何解决这个问题?非常感谢。
我的A布局如下:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/bgColor"
tools:context=".MainActivity" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:orientation="horizontal" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_marginTop="4dp"
android:layout_weight="1"
android:gravity="center" >
<EditText
android:id="@+id/drugText"
android:layout_width="224dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="10"
android:gravity="center_vertical|center"
android:hint="@string/searchHint1"
android:textSize="18sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="3"
android:gravity="left" >
<Button
android:id="@+id/query"
style="@style/ButtonText"
android:layout_width="70dp"
android:layout_height="48dp"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="@drawable/blue_btn"
android:text="@string/search"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_below="@+id/linearLayout1" >
<ListView
android:id="@+id/drugList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clickable="true" />
</LinearLayout>
</RelativeLayout>
以下是我的列表项布局:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/color_listview_border"
android:gravity="center"
android:minHeight="60dp" >
<TextView
android:id="@+id/drugNameTV"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="20sp" />
</LinearLayout>
</LinearLayout>
@Override protected void onResume(){ super.onResume(); Log.e("log", "on resumed"); drugLV.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView> arg0, View arg1, int arg2, long arg3) {.......}});}` 但是它显示以下错误。(错误信息很长,我在这里打印了照片) [链接](http://134.208.3.130/~dickfala/android/err.png) 非常感谢。 我使用ActivityGroup来控制返回。 我的activityGroup代码在这里。[链接](http://134.208.3.130/~dickfala/android/ActivityGroup1.java)
- dickfala@Override protected void onResume(){ super.onResume(); Log.e("log", "on resumed"); });
。当我从B子活动返回到A子活动时,我没有看到日志“on resumed”显示。 @~@ - dickfala