0

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 ??

9
  • You want click on both? the item and button? Commented Sep 23, 2011 at 18:06
  • Yes, and go to diff activities Commented Sep 23, 2011 at 18:13
  • post the code related to clickListeners of the button and the list item. Commented 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); } }); Commented Sep 23, 2011 at 18:17
  • android:onClick="myClickHandler" Commented Sep 23, 2011 at 18:18

2 Answers 2

9

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"

Sign up to request clarification or add additional context in comments.

Comments

0

that is the concept. If u want to implement both clicks then write button click normally and for list item click did not use the listitem click.

Instead that you write onclick listener for converted view that you returned in getview()

Then both clicks will work

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.