I tried with passing context
of activity into the adapter and then i tried context.finish();
But its giving me one error like The method fini
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();
}
});
type cast it with activity.
((Activity)context).finish();
Try passing your Activity as an activity
parameter, then you'll be able to call finish()
on it. Hope this helps.
In your custom adapter try to call finish use below code
((Activity)context).finish();