Skip the headers in PreferenceActivity when there's only one header

前端 未结 4 1812
无人共我
无人共我 2020-12-24 07:48

I added preference-headers to my app so that the preference screen would not look broken on Honeycomb and tablet sized ICS. However, I only have one header at the moment so

4条回答
  •  渐次进展
    2020-12-24 08:47

    Utilizing the EXTRA_SHOW_FRAGMENT mentioned by jenzz, you can manipulate the Activity's Intent, like so:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
      // By default, show MainPreferences
      Intent intent = getIntent();
      if (intent.getStringArrayExtra(EXTRA_SHOW_FRAGMENT) == null) {
        getIntent().putExtra(EXTRA_SHOW_FRAGMENT, MainPreferences.class.getName());
      }
    
      super.onCreate(savedInstanceState);
    }
    

提交回复
热议问题