1

私はHorizo​​ntalScollViewを持っています。これにはLinearLayoutの子があります。SimpleCursorAdapterを(明らかに)バインドできないため、データベースのコンテンツに基づいて作成された子を線形レイアウトに設定するにはどうすればよいですか?

私はもう試した:

    SimpleCursorAdapter summaryItems = new SimpleCursorAdapter(this, R.layout.summary_item, summaryItemsCursor, from, to);
    int count  = summaryItems.getCount();
    View new_view;
    for (int i = 0; i < count; i++) {
        new_view = (summaryItems.newView(this, summaryItemsCursor, mNewsContainer));
        mNewsContainer.addView(new_view);
    }

SimpleCursorAdapter.newView()によって返されるビューが使用可能になることを期待していましたが、明らかに使用できませんでした。私はAndroidにまったく慣れておらず、これを行う正しい方法について完全に迷っています。

参考のためのXML:

<HorizontalScrollView android:id="@+id/news_gallery"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
        <LinearLayout android:id="@+id/news_container"
            android:orientation="horizontal"
            android:layout_height="wrap_content"
            android:layout_width="wrap_content"
            >
        </LinearLayout>
</HorizontalScrollView>

およびsummary_item

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/news_gallery_item"
    android:layout_marginRight="@dimen/news_gallery_item_spacing"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">
    <ImageView android:id="@+id/news_gallery_item_image"
        android:adjustViewBounds="true"
        android:maxHeight="@dimen/news_gallery_image_height"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>
    <TextView android:id="@+id/news_gallery_item_tagline"
    style="@style/news_gallery_text_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
</FrameLayout>
4

2 に答える 2

1

これは、を使用したいように聞こえます(そしてどういうわけか見えます)ListView。チュートリアルはここにあります。

を設定するにはListView、を使用できますSimpleCursorAdapter


水平方向に必要なので、通常のユーザー作成拡張であるHorizonatalListView-classListViewを使用できます(したがって、すべてのメソッドを使用できます)。対応する質問はここにあります。

于 2011-10-06T08:29:51.133 に答える
0

アイテムビューにインフレータを備えたViewBinderでうまくいくはずです

于 2011-10-06T10:05:51.023 に答える