答えて
私がやったことは、灰色と奇妙な色の白い色で塗りつぶされた偶数のセルを持つタスクのリストがあることです。このコードはあなたの目的に合っています。 以下の手順を実行してください:
javaファイルコードは以下のとおりです。これはアダプタクラスのgetViewメソッドのコードです。ここで私はeven odd.Itのコンセプトを使って、すべてのアンドロイドバージョンでうまく動作します。
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflater = context.getLayoutInflater();
View listViewItem = inflater.inflate(R.layout.list_task_data, null, true);
TextView textViewName = (TextView) listViewItem.findViewById(R.id.textViewName);
TextView taskStatusImage = (TextView) listViewItem.findViewById(R.id.taskStatusImage);
TextView textSerialNumber = (TextView) listViewItem.findViewById(R.id.textSerialNumber);
LinearLayout linearLayout = (LinearLayout) listViewItem.findViewById(R.id.firstLayout);
if (position % 2 != 0) {
linearLayout.setBackgroundResource(Color.GRAY);
} else {
linearLayout.setBackgroundResource(Color.WHITE);
}
}
膨張用レイアウトファイルは以下のとおりです。
list_task_data.xml上記のレイアウトではファイル
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/firstLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="@dimen/activity_vertical_margin"
android:weightSum="100">
<TextView
android:id="@+id/textSerialNumber"
android:layout_width="37dp"
android:layout_height="37dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="5dp"
android:gravity="center"
android:text="text"
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="15dp" />
<TextView
android:id="@+id/textViewName"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_weight="30"
android:descendantFocusability="blocksDescendants"
android:fontFamily="@string/font_family_universal"
android:padding="5dp"
android:text="New Text"
android:textAlignment="center"
android:textIsSelectable="false"
android:textSize="20dp"
/>
<TextView
android:id="@+id/taskStatusImage"
android:layout_width="35dp"
android:layout_height="35dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5dp"
android:layout_marginRight="10dp"
android:gravity="center"
android:text=""
android:textAlignment="center"
android:textColor="@color/black"
android:textSize="10dp" />
</LinearLayout>
のためのコードは、リストビューのセルに膨らま何があります。 また、選択肢ごとにif else条件でテキストの色のフォントサイズなどの他のプロパティを変更するコードを追加することもできます。
希望のサンプルコードを参考にしてください。
メカニズムはセレクタと同じでなければなりません....選択されたリストのみがデザインを取得します –
私のコードでリスト偶数/奇数セルのコンセプトに基づいてセルに背景色を与えたので、特定のセルの背景を色付けしたい場合は、ロジックを追加して、それを色付けし強調表示するコードを使用することができます。 –
あなたは十分にコード化されていますが、ロジックとコードを実際に追加するのではなくセレクタが必要です –
- 1. 選択時にテーマの背景色とテキストの色を変更する方法
- 2. 背景色とテキスト色をJavascriptのタイマーで変更します
- 3. Java - メニューバーとアイテムの背景とテキストの色を変更する
- 4. UIDocumentInteractionControllerを変更する方法ボタンのテキストと背景の色を完了
- 5. アンドロイドでトーストの背景色、背景色、テキスト色をカスタマイズする方法
- 6. ItemDelegateの背景とテキストの色を変更する
- 7. セレクタを使用してListViewの背景色を変更する
- 8. テキストと背景色を変更するには?
- 9. reCaptchaイメージのテキストと背景色を変更する
- 10. XAML背景色とテキストの色が変更されない
- 11. ビジュアルスタジオ2010ツールチップの背景色または前景色を変更する方法
- 12. ListViewの行の背景色をListActivityから変更します
- 13. Qtでは、スライダの背景色を変更する方法は?
- 14. (C#WPF)テキストの背景色を変更するには?
- 15. GDI +グラフィックスメソッドを使用してテキストの前景色と背景色を変更する - 色を変換する
- 16. Winform ListViewヘッダーの背景色を変更します
- 17. PyCharmの一致するテキストの背景色を変更する
- 18. SVGイメージの背景色を変更する方法は?
- 19. 右クリックでドロップダウンメニューの背景色を変更する方法は?
- 20. AjaxControlToolkit HtmlEditorExtenderコントロールの背景色を変更する方法は?
- 21. 変更背景色
- 22. Vim通常の背景フォアグラウンドのテキストの色を変更する
- 23. Windowsコンソールアプリケーションでテキストまたは背景色を変更する方法
- 24. Android背景画像に応じてテキストの色を変更する方法
- 25. Android - ListViewの行の背景色の変更
- 26. Eclipseの背景色のテキストを変更する
- 27. プレースオートプレイトフラグメントの前景色と背景色を変更します
- 28. ListView位置の背景色を変更してください
- 29. 変更ポップアップメニューの背景色
- 30. 変更メニューの背景色
色を交互に変更したいですか? –
背景と行の項目を設定 –
バッターソリューション用にここにコードを投稿できますか?または、あなたがしたいことを正確に説明してください。 –