[英]Adapter for data-biding on gridview
我有一个gridview
<GridView
android:id="@+id/gridViewProduit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:numColumns="3" >
</GridView>
并且我已经将GridView与以下布局绑定:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/hdn_txt_code"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/txv_des"
android:layout_width="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:layout_height="wrap_content" />
</LinearLayout>
为此,我使用了像这样的SimpleAdapter:
SimpleAdapter produitAdapter = new SimpleAdapter(this.getBaseContext(),
familleItem, R.layout.affiche_famille_produit, new String[] {
"CODE", "DESIGNATION" }, new int[] { R.id.hdn_txt_code,
R.id.txv_des });
我将需要多次刷新此gridview,并且在SimpleAdapter的文档中说该Adapter用于静态数据,但不是我的情况。 我正在寻找一个允许我像我的SimpleAdapter允许我那样在我的网格视图上绑定日期的适配器。 谢谢
如果适配器中的数据已更改,那么您只需在适配器上调用notifyDataSetChanged ,网格将重新填充
我认为解决方案是重写ArrayAdapter并在getView方法上绑定数据
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.