以下是我的 ListActivity,onCreate 代码
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fakeTripBuilder();
setContentView(R.layout.cutom_list_view);
SimpleAdapter adapter = new SimpleAdapter(this, list, R.layout.custom_row_view,
new String[] {"stop","distance","time","icon","mode"},
new int[] {R.id.text_stop,R.id.text_distance, R.id.text_time, R.id.icon, R.id.text_mode});
populateList();
setListAdapter(adapter);
}
在同一个类中我有以下方法
@Override
protected void onListItemClick(ListView l, View v, int position, long id){
super.onListItemClick(l, v, position, id);
Log.d("Travel","You choosed!");
Object o = this.getListAdapter().getItem(position);
Toast.makeText(this, "You Choosed"+o.toString(), Toast.LENGTH_LONG).show();
}
这是“custom_list_view.xml”
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:clickable="false"
android:gravity="center_horizontal|center_vertical"
android:orientation="vertical" >
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000fff"
android:layout_weight="2"
android:drawSelectorOnTop="false">
</ListView>
<TextView
android:id="@id/android:empty"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFff00"
android:text="No data"
/>
</LinearLayout>
问题是,当我点击它时不会调用 onListItemClick 方法。帮助 !!