listview
以下は、 3 を含むデータを表示するためのコードとスクリーンショットを示していますtextview
。
getView()
クラスのメソッドで次のコードを試して、Adapter
背景画像を交互の行、つまり行番号に割り当てました。0、2、4など
これを実装しようとすると、スクリーンショットに示すような出力が得られます。つまり、行が適切に影響を受けません。
また、パラメータが使用されxml
ている以下を参照してください。ボタンをクリックしても、2番目と3番目は背景色を適切に取得していません。alignTop
alignBottom
Index
textview
Index
編集 - 背景に画像の代わりに色を使用すると、ボタンを除くすべてのケースでうまく機能します。
if (count % 2 == 0) {
try {
InputStream is = ctx.getAssets().open("cellbg.png");
Drawable d = Drawable.createFromStream(is, "cellbg");
holder.txtFirst.setBackgroundDrawable(d);
holder.txtSecond.setBackgroundDrawable(d);
holder.txtThird.setBackgroundDrawable(d);
Log.v("count=", "" + (count++));
} catch (Exception e) {
throw new Error(" exception in TableListAdapter " + e.getMessage());
}
} else {
Log.v("else count==", "" + (count++));
}
リスト構造(xml)
<TextView
android:id="@+id/FirstText"
android:layout_width="80dp"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/SecondText"
android:layout_width="55dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/FirstText"
android:layout_alignBottom="@+id/FirstText"/>
<TextView
android:id="@+id/ThirdText"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/FirstText"
android:layout_alignBottom="@+id/FirstText"/>
最初の画面は、アプリケーションの起動時のリスト構造を示しています。デフォルトでは、Gainers
ボタンが押されています。
2番目は、ボタンを押すインスタンスを示していIndex
ます。
Gainers
3番目は、インデックスボタンを押した後、もう一度ボタンを押すインスタンスを示しています。
List item
4 番目は、をクリックしたときのレイアウトを示しています。
私は何を間違っていますか?
どんな助けでも命の恩人になります!!!