ドメイン モデルのリストを表示するアプリケーションを作成しています。デフォルトの動作では、これらのモデルはListView
. ユーザーがこのデータをリストとして表示するか、GridView
. そうするための慣用的な方法は何ですか?
私のドメイン モデルは単純な pojo です。そのCustomArrayAdapter
ための と、現在次のようなカスタム行レイアウトを作成しました。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TextView
android:id="@+id/label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@+id/label" >
</TextView>
<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_marginLeft="25dp"
android:layout_toRightOf="@+id/label"
android:text="@+id/text" />
</RelativeLayout>
ArrayAdapter
両方のレイアウトに同じものを使用したいと考えています。
私の活動のレイアウトはかなり単純です:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
tools:context=".MainActivity" >
<!-- what do I put here? -->
</RelativeLayout>