我无法在 android 的列表中单击项目,这是我的代码:
list=(ListView) findViewById(R.id.list);
list.setOnItemClickListener(this);
TaskListAdapter obj = new TaskListAdapter(this.getApplicationContext()
,R.layout.row, tl);
list.setAdapter(obj);
//list.setItemsCanFocus(true);
list.setClickable(true);
这是列表适配器
LayoutInflater loi = LayoutInflater.from(con);
View v = loi.inflate(rid, parent, false);
TextView tv1 = (TextView) v.findViewById(R.id.txt1);
TextView tv2 = (TextView) v.findViewById(R.id.txt2);
//iv.setBackgroundResource(arrow);
v.setClickable(true);
v.setFocusable(true);
final int pos = position;
tv1.setText(objs.get(position).GuestName);
tv2.setText(objs.get(position).TaskID);
return v;
这是我的点击项处理程序
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
// Intent in = new Intent();
// in.putExtra("GuestID", tl.get(arg2).GuestID);
// in.putExtra("ReservationID", tl.get(arg2).ReservationID);
// in.putExtra("CustomerID", custId);
// in.putExtra("Token", token);
getGuestDetails(tl.get(arg2).GuestID, tl.get(arg2).ReservationID);
}
这是xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:background="#f1eff0">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="wrap_content"
android:stretchColumns="1" android:gravity="center_vertical"
android:background="@drawable/toptab" android:id="@+id/tb1">
<TableRow>
<Button android:id="@+id/btnback" android:background="@color/hover_bckbtn"
android:text="Back" android:textColor="#ffffff" android:textSize="14sp"
android:textStyle="normal" android:typeface="normal"
android:layout_marginLeft="5dp" />
<TextView android:id="@+id/tvnormalcallreg" android:text="List View"
android:textColor="#ffffff" android:textSize="18sp"
android:layout_gravity="center" android:textStyle="normal"
android:typeface="normal" />
<Button android:id="@+id/btnregister" android:textColor="#ffffff"
android:background="@color/hover_button" android:text="Register"
android:textSize="14sp" android:textStyle="normal" android:typeface="normal"
android:layout_marginRight="5dp" />
</TableRow>
</TableLayout>
<ListView android:id="@+id/list"
android:scrollbars="none"
android:layout_below="@+id/tb1"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_width="fill_parent"
android:cacheColorHint="#00000000"
android:fadingEdge="none"
android:layout_marginBottom="50dp"/>
<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content" android:layout_alignParentBottom="true"
android:id="@+id/bottom">
<TableRow android:background="@drawable/toptab"
android:gravity="center">
<ImageView android:layout_width="wrap_content"
android:layout_height="wrap_content" android:background="@drawable/logobottom" />
</TableRow>
</TableLayout>
</RelativeLayout>
请帮助我,我是android的新手??