代码之家  ›  专栏  ›  技术社区  ›  marcc

Android中水平滚动视图中的ListView

  •  0
  • marcc  · 技术社区  · 16 年前

    我有一个 ListView HorizontalScrollView _myListAdapter.notifyDataSetChanged(); 并且数据在数据库中变得可见 . 但是如果 列表视图 视图 列表视图 notifyDataSetChanged 没有作出决定 滚动到当前视图?

    以下是我如何创建布局XML文件的想法:

    <HorizontalScrollView 
        android:id="@+id/my_scrollview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" 
        android:scrollbars="none">
    
            <LinearLayout android:id="@+id/my_layout"
                android:layout_width="wrap_content"
                android:layout_height="fill_parent"
                android:orientation="horizontal">
    
                    <ListView android:id="@+id/my_list"
                        android:layout_width="fill_parent"
                        android:layout_height="fill_parent"
                        android:layout_weight="1" />
    
            </LinearLayout>
    
    </HorizontalScrollView>
    
    1 回复  |  直到 16 年前
        1
  •  0
  •   Dan Lew    16 年前

    我会在你打电话之前让你的ListView不可见 notifyDataSetChanged()

    <ListView android:id="@+id/my_list"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_weight="1"
        android:visibility="gone"/>
    

    _myListAdapter.notifyDataSetChanged();
    ListView listView = (ListView) findViewById(R.id.my_list);
    listView.setVisibility(View.VISIBLE);
    

    不确定这是否有效。。。不过值得一试。

    推荐文章