I have a ListView. on click of a list item I start a Activity. Now I have added a Button on that ListView and onclick of a button I want to start a another activity. After adding a Button, I can click on the button and start a Activity but now I can not click a list item. What happened to listview's item click ??
-
You want click on both? the item and button?Ron– Ron2011-09-23 18:06:18 +00:00Commented Sep 23, 2011 at 18:06
-
Yes, and go to diff activitiesuser533844– user5338442011-09-23 18:13:22 +00:00Commented Sep 23, 2011 at 18:13
-
post the code related to clickListeners of the button and the list item.Urban– Urban2011-09-23 18:16:47 +00:00Commented Sep 23, 2011 at 18:16
-
public void onItemClick(AdapterView<?> adapterView, View v, int arg2, long arg3) { Intent i = new Intent(getBaseContext(), TaskDetails.class); i.putExtra("TaskID", cursor.getString(cursor.getColumnIndex("TaskID"))); i.putExtra("EmpID", empid); startActivity(i); } });user533844– user5338442011-09-23 18:17:57 +00:00Commented Sep 23, 2011 at 18:17
-
android:onClick="myClickHandler"user533844– user5338442011-09-23 18:18:32 +00:00Commented Sep 23, 2011 at 18:18
|
Show 4 more comments
2 Answers
Read this excellent blog post: Focus problems with list rows and ImageButtons
Essentially you should add the following to your root layout element in the row-item xml.
android:descendantFocusability="blocksDescendants"