android - Custom Listview with checkbox not clickable -


I created a custom list view with checkbox, items on the list view are not clickable I want to enable the checkboxes not just to click the items in the list. store.getText () toString (); list.add (data); ArrayAdapter & LT; String & gt; Adapter = New ArrayAdapter & lt; String & gt; (MainActivity.this, R.layout.list_view, R.id.textView1, list); LSet adapter (Adapter);}}); ls.setOnItemClickListener (New OnItemClickListener () {@Override public void onItemClick (AdapterView & LT ;? & gt; arg0, see ARG1, ARG2 integer, long arg3) {string click = list.get (ARG2) .toString (); Toast .makeText (GetBaseContext (), "you clicked" + click, toast .LENGTH_SHORT) .show ();}});

list_view.xml

  & lt; Checkbox android: id = "@ + id / checkbox1 my Android code for": Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: Leaut_algpriwartk = "true" Android: Leaut_alginpecrtop = "true" / & gt; & Lt; TextView android: id = "@ + id / textView1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignBaseline = "@ + id / checkBox1" Android: layout_alignBottom = "@ + id / checkBox1" Android: Layout_triteoff = "@ + ID / checkbox" Android: Text = "" />   

My activity_main.xml file

  & lt; ListView android: id = "@ + id / list" Android: layout_width = "Match_parent" Android: layout_height = "wrap_content" android: layout_alignParentLeft = "true" Android: layout_below = "@ + id / editText1" & gt; & Lt; / ListView & gt; & Lt; EditText android: id = "@ + id / editText1" Android: layout_width = "wrap_content" Android: layout_height = "wrap_content" Android: layout_alignParentLeft = "true" Android: layout_alignParentTop = "true" Android: EMS = "10" / & gt ; & Lt; Button android: id = "@ + id / btnSave Save" Android: Layout_width = "Wrap_content" Android: Layout_height = "Wrap_content" Android: layout_alignParentRight = "true" Android: layout_alignTop = "@ + id / editText1" android: text = " "/>    

This does not work because checkboxes to Adding ListView ListView by sticking the focus you are not able to click on the list item. There is not a solution, do not use the checkbox, but instead you can use the parameter setClickable (right) or XML with the android for example Drawable, ImageView or TextView: Clickable = single This is the truth ???? This will work because you will not lose the focus of ListView

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -