The screen flickers and requires an additional button press after returning from PreferenceActivity

I added the Simple PreferenceActivity application to the application, accessible through the context menu button. I can access PreferenceActivity and everything that works there. The problem is that you are leaving PreferenceActivity with the back button. The main activity of the application appears again, but then the whole screen dims, almost the same way as a dialog box appears, or the context menu never disappeared, but no. You cannot interact with a ListActivity that is in the background without pressing the back button or menu button.

Anyone have any idea why this will happen?

Primary activity:

@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); // get the inflater MenuInflater inflater = getMenuInflater(); // inflate inflater.inflate(R.menu.main_menu, menu); return true; } 

@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection; switch(item.getItemId()) { case R.id.refresh: refresh(); return true; case R.id.subreddits: startActivity(new Intent(this, Prefs.class)); return true; default: return super.onOptionsItemSelected(item); } }

PreferenceActivity:

 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.subreddit_preferences); } 
+4
source share
2 answers

I would not write onCreateOptionsMenu() this way. Instead of calling super first and then returning true , return the chain results to the superclass.

If this does not help, here is an example project that uses PreferenceActivity and does not suffer from the problems you quote. See if you can determine where your code is different from what I have.

+4
source

I had the same problem and my problem was that I placed a submenu in my menu item "Settings".

Removal fixed.

0
source

Source: https://habr.com/ru/post/1345624/


All Articles