【问题标题】:How to scroll to specified item in PreferenceActivity?如何滚动到 PreferenceActivity 中的指定项目?
【发布时间】:2013-02-26 06:15:27
【问题描述】:

我的应用有一个全局首选项,其中包含所有活动的设置。如果我点击不同活动中的设置,我希望PreferenceActivity 自动滚动到该活动的设置部分。

我尝试使用getListView().setSelection(i)来实现这个功能。但是,在onCreate()onResume() 中,getListView() 尚未初始化。

我怎么知道PreferecneActivityListView什么时候会被初始化,或者有没有其他方法可以实现这个功能?

【问题讨论】:

    标签: android scroll preference


    【解决方案1】:

    你可以在onResume()getView().post(new Runnable());试试

    因为视图必须在创建后调度。并且在 runnable 中做你的工作是可以的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-09-06
      • 1970-01-01
      • 2012-04-26
      • 1970-01-01
      • 1970-01-01
      • 2011-02-23
      相关资源
      最近更新 更多