I am unable to click item on my list in android here is my code:
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);
Here is the list adapter
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;
here is my click item handler
@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);
}
here is the 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>
Please help me I am new in android??
Problem Solved
I commented out these lines
v.setClickable(true);
v.setFocusable(true);
and my code worked
Do you actually have a click listener? I can see you set the click listener to this , but you haven't added the code showing the implementation of the click listener.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.