ArrayAdapter

Android開発に関するメモランダム

カテゴリー: 家計簿アプリ  閲覧数:415 配信日:2013-08-31 21:07


手順


▼/src/android/style/householdaccount/MainActivity.java
onCreateメソッド内
・cursorメソッド新規作成

1.Listの作成
・ListViewに表示したいデータを作成

2.Adapterの作成
Adapterはデータを担当するListと、UIを担当するListViewの橋渡しをするコンポーネント
・Adapterでは、Listに格納されたアイテム1つずつのViewを生成し、ListViewに表示
・Adapterのコンストラクタ引数にListを入れると、対象のListのAdapterになる
・よく使われるArrayAdapterクラスを使用
    	// ListViewにAdapterを関連付ける
       ListView list1 = (ListView) findViewById(R.id.list1);
     list1.setAdapter(adapter);
     list1.setOnItemClickListener(new ClickEvent());

findViewByIdメソッド
▼/res/layout/activity_main.xml
		<ListView
android:id="@+id/list1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="@color/yellow"
android:divider="#00000000"
/>
</LinearLayout>

	  	<ListView
android:id="@+id/list1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
/>


Androidコンポーネント初級編#1 : ListViewの使いかた | Developers.IO

週間人気ページランキング / 2-16 → 2-22
順位 ページタイトル抜粋 アクセス数
アクセスが、ありませんでした! 0
2025/2/23 1:01 更新
指定期間人気ページランキング / 1970-1-1 → 2025-2-22
順位 ページタイトル抜粋 アクセス数
アクセスが、ありませんでした! 0
2025/2/23 1:01 更新