原理
PreferenceActivity类中有一个静态变量 EXTRA_SHOW_FRAGMENT
/**
* When starting this activity, the invoking Intent can contain this extra
* string to specify which fragment should be initially displayed.
* <p/>Starting from Key Lime Pie, when this argument is passed in, the PreferenceActivity
* will call isValidFragment() to confirm that the fragment class name is valid for this
* activity.
*/
大意:开启acitivity活动时,可以通过intent包含额外的数据(类型:EXTRA_SHOW_FRAGMENT)来指定最开始展示的fragment
public static final String EXTRA_SHOW_FRAGMENT = ":android:show_fragment";
网友评论