Answer the question
In order to leave comments, you need to log in
How to close PreferenceFragment programmatically?
I created a template AppCompatPreferenceActivity in android studio with PreferenceFragment headers.
It has an ActionBar with a home button. It is processed in the header like this:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) {
startActivity(new Intent(getActivity(), SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
Answer the question
In order to leave comments, you need to log in
call onBackPressed() on the activity instead of startActivity() for example.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question