我刚刚开始编程前不久,所以请裸露在我身边。更改ListView中的项目的颜色和ClickEvent(Xamarin Android)
我面临的问题是我无法将列表视图中我的项目的颜色更改为黑色。
我的ListView的背景(我已经删除了,以便看到Listview中的项目)也应该是白色背景。
在我的活动中,我使用adapter.add(“Item”)添加了我的项目。因此,我失去了尝试在该项上添加单击事件,因为它是一个字符串。
试过:
1)直接在axml文件中更改属性。如android:textColor/Foreground等。
2)添加一个color.xml文件并声明它的颜色。然后调用该颜色变量到我的列表视图组件“android:thatcolorname”
3)试图改变它从我的编码内我的活动。如mLeftItems.Foreground/TextColor等甚至尝试使用android.graphics.color等它不适合我。
我对我的列表视图编码是
mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.myDrawer);
mLeftDrawer = FindViewById<ListView>(Resource.Id.leftListView);
mLeftItems.Add("Add Device");
mLeftItems.Add("Disconnect Device");
mLeftAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleListItem1, mLeftItems);
mLeftDrawer.Adapter = mLeftAdapter;
对于我.axml文件,它是
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myDrawer"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<!-- The left navigation drawer -->
<ListView
android:id="@+id/leftListView"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="left"
android:choiceMode="singleChoice"
android:divider="#D2D2D2"
android:dividerHeight="2dp" />
</android.support.v4.widget.DrawerLayout>
任何指导或帮助是非常赞赏。