Android 앱에서 작업을 나열하는 Listview가 있습니다. 작업 유형에 따라 행의 색을 지정하고 싶습니다. 다음은 Listview를 설정하는 데 사용하는 코드입니다.Listview에서 개별 행의 배경색을 개별적으로 설정합니다.
startManagingCursor(cursor);
adapter = new SimpleCursorAdapter(this, R.layout.menu_item, cursor, FROM, TO);
menuList.setAdapter(adapter);
다음은 목록보기 항목의 Xml 레이아웃입니다.
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="10sp">
<TextView
android:id="@+id/rowid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/exhibitor_header" />
<TextView
android:id="@+id/rowidtwo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/listview_background"
android:layout_below="@+id/rowid"/>
</RelativeLayout>
각 작업 열과 관련된 색으로 각 행을 표시하도록 어떻게 설정합니까? 사용자 지정 어댑터를 사용하지 않고도이 작업을 수행 할 수 있습니까?
사용자 정의 어댑터 없이는 할 수 없다고 생각합니다 ... 자신 만의 SimpleCursorAdapter를 작성해야합니다 ... – krackmoe
해당 어댑터를 사용하십시오 .. – user370305