Reputation: 602
Hi I'm calling an activity with ImageButton click but it would not finish the current activity.
btn_home.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent i = new Intent(getApplicationContext(), GridActivity.class);
i.putExtra("feed", _rssFeed);
startActivity(i);
SwipeDetailView.this.finish();
}
});
However, if I click the home button on the Actionbar menu within the same class, it closes fine.
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Upvotes: 2
Views: 5641
Reputation: 3284
You are calling finish on the View.OnClickListener
context instead you need to do ACTIVITYCLASSNAME.this.finish ()
Upvotes: 5