Android:ListView导致requestLayout()被错误地调用

时间:2014-08-09 05:53:50

标签: android listview android-listview android-logcat

在我的ListView中启用快速滚动导致以下错误:

08-09 01:47:33.294 10816-10816/com.exampleW/View﹕ requestLayout() improperly called by android.widget.TextView{...} during layout: running second layout pass

我知道ListView导致了这个问题,因为从ListView的XML中删除以下代码行会删除错误:

android:fastScrollEnabled="true"

有没有办法解决这个错误?为了彻底,我还包括了TextView的XML:

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content" />

2 个答案:

答案 0 :(得分:0)

我认为这个错误不是因为android:fastScrollEnabled =“true”但请尝试下面的java文件中的代码..

尝试list.smoothScrollToPosition(0);还有android:fastScrollEnabled =“true” 以便在调用滚动时显示数据...

像这样......

 new Handler().postDelayed(new Runnable()
 {
          @Override
          public void run()
          {
              list.smoothScrollToPosition(0);
          }
 }, 100);

答案 1 :(得分:0)

当你设置fastScrollEnabled = true时,这是Android实现中的已知错误,它出现在某些Android版本中。

https://code.google.com/p/android/issues/detail?id=75516

除了丑陋的控制台垃圾邮件与上面的调试消息,似乎没有其他影响(在某些情况下可能性能,我还没有测试)。