9

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.

Tofeeq Ahmad
  • 11,935
  • 4
  • 61
  • 87
Sundeep
  • 375
  • 2
  • 4
  • 16

3 Answers3

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
0

Get you activity context, and after that you can do your_context.finish().

Ritaban
  • 763
  • 4
  • 8