私はHorizontalScollViewを持っています。これには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>