我有下一个结构:
ArrayList<String> arrayList = new ArrayList<>();
list = (ListView) findViewById(R.id.list1);
arrayAdapter = new ArrayAdapter<String>(INGR_NOTAS.this, R.layout.list_item_clickable, R.id.txtitem, arrayList);
list.setAdapter(arrayAdapter);
Run Code Online (Sandbox Code Playgroud)
listview 的布局来自 list_item_clickable.xml 和里面的 textiview "txtitem":
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="TextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/txtitem"
android:textColor="@android:color/white"
android:background="@android:drawable/editbox_dropdown_dark_frame"
android:textAlignment="center" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
这个结构在很多类中都有效,就像 Textview 所说的,textcolor 总是白色,但现在我需要根据文本的值(有时是白色,有时是红色)更改列表视图内的文本颜色。那么,如何添加此更改而不会对所有应用程序的其余代码产生很大影响????
感谢您的任何建议!