How to finish an activity from an Adapter..? How to finish an activity from an Adapter..? android android

How to finish an activity from an Adapter..?


type cast it with activity.

((Activity)context).finish();


Try with the following code:

public YourAdapterName(......,Context context){...this.myContext=context;}

And in your adapter getView()

btn.setOnClickListener(new Button.OnClickListener() {    @Override    public void onClick(View v) {        ((YourActivityName)myContext).yourDesiredMethod();    }});


Try passing your Activity as an activity parameter, then you'll be able to call finish() on it. Hope this helps.