小智..
13
我有同样的问题:OnListItemClick没有被解雇![已解决]
这种情况发生在扩展ListActivity的类上,其中ListActivity
的布局将内容TextBox和ListView嵌套到LinearLayout中
,另一个布局用于行(CheckBox和TextBox嵌套到LineraLayout中).
这是代码:
res/layout/configpage.xml(ListActivity的主要内容)
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
android:id="@+id/selection"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="pippo" />
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:drawSelectorOnTop="false"
android:background="#aaFFaa" >
res/layout/row.xml (layout for single row)
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
**android:focusable="false"**
**android:focusableInTouchMode="false"** />
android:id="@+id/testo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
**android:focusable="false"**
**android:focusableInTouchMode="false"** />
src /.../.../ ConfigPage.java
public class ConfigPage extends ListActivity
{
TextView selection;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.configpage);
// loaded from res/value/strings
String[] azioni = getResources().getStringArray(R.array.ACTIONS);
setListAdapter(new ArrayAdapter<String>(this, R.layout.row,
R.id.testo, azioni));
selection = (TextView) findViewById(R.id.selection);
}
public void onListItemClick(ListView parent, View view, int position, long id)
{
selection.setText(" " + position);
}
}
当我在row.xml上添加时,这开始起作用
android:focusable="false"
android:focusableInTouchMode="false"
我使用Eclipse 3.5.2
Android SDK 10.0.1
min SDK版本:3
我希望这
对我有帮助......对不起我的英语:(