简体   繁体   English

android上的首选项视图不是片段

[英]Preference view on android not being a fragment

For the preference view, I have seen examples where its created an activity, then its created a PreferenceFragment and put it inside the new activity. 对于首选项视图,我看到了一些示例,在该示例中创建了一个活动,然后创建了一个PreferenceFragment并将其放在新活动中。

  1. Why the preference view has to be a fragment and not just the layout for the new activity without it being a fragment? 为什么首选项视图必须是一个片段,而不仅仅是新活动的布局而不是一个片段?

Thanks 谢谢

You only create and activity when you need, first think about it. 您仅在需要时创建和活动,然后再考虑一下。

Rule #1 Create an Activity only if it's absolutely absolutely required. 规则1:仅在绝对必要时才创建活动。

In this case if you think in details, you dont need to use an new Activity, the practical and best way is load a fragment. 在这种情况下,如果您考虑得很详细,则无需使用新的Activity,实用且最佳的方法是加载片段。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM