I have successfully made a custom list view using base adapter. However, I wish to create a on click listener for each row item. For example I press any row it does XYZ blah blah.
Can someone help me find an example of how this is done? I was trying a google search earlier and I cant find an example of it being used with list view base adapter.
Thank you
I think the best way to achieve it is finding the View
in your getView()
method of your custom Adapter
.
The second parameter (usually called convertView
, but doesn't have to) represents each one of the rows of your ListView
. There's where you would declare your onClickListener
, for example:
@Override
public View getView(final int position, View convertView, final ViewGroup parent) {
...
convertView.setOnClickListener(...);
...
}
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.