我仍然有一個ListView點擊處理程序的問題。該事件沒有被解僱,所以 我沒有看到調試信息。Android ListView - 點擊處理程序不工作
我想,而不是使用ListActivity
這裏再一次的活動是我的代碼:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Capture our button from layout
//appState = ((MyApp)getApplicationContext());
setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
//requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.listr);
//setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.fishicon);
setupDB();
populateList3();
ListView lv = (ListView) findViewById(R.id.list);
// lv.setClickable(true);
lv.setOnItemClickListener(new OnItemClickListener() {
//@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Toast.makeText(ListRecords.this,"Clicked!", Toast.LENGTH_LONG).show();
}
});
下面是XML文件:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:orientation="vertical"
android:gravity="center"
android:layout_height="fill_parent">
<!--Put form controls here-->
<ListView
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="400dp" />
<Button
android:id="@+id/previousbutton"
android:gravity="center_horizontal"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:text="Previous Menu"/>
</LinearLayout>
我想不通爲什麼點擊監聽器不管用。
感謝 邁克
你點擊按鈕或列表中的項目?你如何填寫名單? – 2011-03-10 16:42:53