how to return to the previous PrefenenceScreen from nested PreferenceScreen without press the back button

前端 未结 4 700
小鲜肉
小鲜肉 2021-01-06 17:19

I have write a multi-level Preferences in program with xml File. and i want to know how to return to the previous level without press the back button. how to write some code

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-06 18:22

    You can simulate the press of the back button:

    this.onBackPressed();
    

    or

    getActivity().onBackPressed();
    

    if you are in a fragment.

提交回复
热议问题