Make an entire row in a ListView clickable?

I have some problems with my ListView. In a fist, I create my project for android v2.2. No. I build the same in version 2.1. My problem now is that in my list the whole line is no longer clickable, but only the text can be clicked. How can I do my whole line again?

Alex

Edit: I am using a simple adapter.

Edit2: My code:

setListAdapter (new ArrayAdapter <String> (myEvents.this, R.layout.list_item, titleList)); ListView list = getListView(); list.setTextFilterEnabled(true); list.setOnItemClickListener(new OnItemClickListener(){ public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) { // here is an alert dialog } } 
+4
source share
1 answer

You can do something like this ...

override getview of a simple adapter, as shown in this link .

In the adapter ..

 View getView(......) { // set the tag of the text view object textView.setTag(data); textView.setOnClickListner(myOnClick); } 

Member on the client.

 public OnClick myOnClick = new Onclick( void onclick(View v) { Object data = view.getTag(); // do something based on the data.. } ); 

Hope this helps ...

+1
source

Source: https://habr.com/ru/post/1389690/


All Articles