Farbe für alle Textviews in Reihe setzen i ein listadapter wie das Bild erstellt haben unten und die Textviews von hashmap wie dieseWie in listadapter
HashMap<String, String> kursiShitje = new HashMap<>();
for (int i = 0; i < 6; i++) {
kursiShitje.put("text_1", "Shitje");
JSONObject c = values.getJSONObject(i);
String name = c.getString(TAG_SELL);
kursiShitje.put("text_" + (i + 2), name);
}
Hier bevölkern die listadapter:
ListAdapter adapter = new SimpleAdapter(
MainActivity.this, kursiKembimit,
R.layout.list_rows, new String[]{"text_1", "text_2", "text_3", "text_4", "text_5", "text_6", "text_7"},
new int[]{R.id.text1, R.id.text2, R.id.text3, R.id.text4, R.id.text5, R.id.text6, R.id.text7}) {
list_rows.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rows"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingLeft="10dp"
android:paddingRight="10dp">
<TextView
android:id="@+id/text1"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/text2"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"/>
<TextView
android:id="@+id/text3"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/text4"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/text5"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/text6"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
/>
<TextView
android:id="@+id/text7"
android:layout_width="180dip"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-bold"
android:gravity="right"
android:textColor="@color/white"
android:textSize="30sp"
android:textStyle="bold"
/>
</LinearLayout>
Die Frage ist, wie setze ich eine eindeutige Textfarbe für jede Zeile in der Liste. Ich kann Farbe für alle Textansichten mit overriding getView festlegen, aber ich möchte für jede Zeile eine eindeutige Farbe festlegen. Ich kann nicht herausfinden, wie man es löst.
Sie müssen Ihren benutzerdefinierten Adapter verwenden !! –
ich meine baseadapter oder arrayadapter –
show 'R.layout.list_rows' diese XML-Datei? –