I have an activity with a ListView that loads data from a web service. I have a button in each list item which is loaded through custom adapter class. I am handling the button events in the adapter class. Now what I need is to finish the activity with ListView from the adapter class in the button click event.
Asked
Active
Viewed 1.1k times
3 Answers
16
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
((Activity)context).finish();
}
});
use this code on button click event

NikhilReddy
- 6,904
- 11
- 38
- 58
0
You can use ((Activity)context).finish();
method.

AskNilesh
- 67,701
- 16
- 123
- 163

Vishal Pawale
- 3,416
- 3
- 28
- 32