use home button to return from preferences

This commit is contained in:
Zeapo 2014-08-07 00:15:07 +01:00
parent 19b48565f4
commit 835bbc01dc
2 changed files with 18 additions and 5 deletions

View File

@ -78,6 +78,7 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
System.out.println("Exception caught :(");
e.printStackTrace();
}
this.leftActivity = true;
return true;
case R.id.menu_add_password:
@ -91,11 +92,6 @@ public class PasswordStore extends Activity implements ToCloneOrNot.OnFragmentI
refreshListAdapter();
return true;
case android.R.id.home:
getFragmentManager().popBackStack();
return true;
default:
break;
}

View File

@ -2,6 +2,7 @@ package com.zeapo.pwdstore;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.view.MenuItem;
public class UserPreference extends PreferenceActivity {
@ -12,4 +13,20 @@ public class UserPreference extends PreferenceActivity {
getActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
switch (id) {
case android.R.id.home:
setResult(RESULT_OK);
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}