Xamarin.android 如何向ListView添加文本颜色
如何向ListView添加文本颜色? 背景是白色的布局,我需要的文本颜色是暗灰色或黑色 --用户界面Xamarin.android 如何向ListView添加文本颜色,xamarin.android,Xamarin.android,如何向ListView添加文本颜色? 背景是白色的布局,我需要的文本颜色是暗灰色或黑色 --用户界面 --代码: listV=findviewbyd(Resource.Id.ListView1); itemlist=新列表(); 项目列表。添加(“项目1”); 项目列表。添加(“项目2”); 项目列表。添加(“项目3”); 项目列表。添加(“项目4”); 项目清单。添加(“项目5”); 项目列表。添加(“项目6”); 项目清单。添加(“项目7”); 项目列表。添加(“项目8”); Array
--代码:
listV=findviewbyd(Resource.Id.ListView1);
itemlist=新列表();
项目列表。添加(“项目1”);
项目列表。添加(“项目2”);
项目列表。添加(“项目3”);
项目列表。添加(“项目4”);
项目清单。添加(“项目5”);
项目列表。添加(“项目6”);
项目清单。添加(“项目7”);
项目列表。添加(“项目8”);
ArrayAdapter=新的ArrayAdapter(这个,Android.Resource.Layout.SimpleListItem1,itemlist);
listV.Adapter=适配器;
谢谢创建一个布局文件,其中包含您想要的文本视图,其中包含您喜欢的文本大小、文本样式、颜色等,然后将其与ArrayAdapter一起使用 e、 g.mytextview.xml
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tview"
android:textColor="@color/yourColor"
android:padding="5sp"
android:layout_width="fill_parent"
android:background="@drawable/rectgrad"
android:singleLine="true"
android:gravity="center"
android:layout_height="fill_parent"/>
然后像往常一样与ArrayAdapter一起使用
ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, R.layout.mytextview, itemlist);
ArrayAdapter adapter=新的ArrayAdapter(this,R.layout.mytextview,itemlist);
为此使用LinearLayout或RelativeLayout?我遇到了以下错误:Java.Lang.IllegalStateException:ArrayAdapter要求资源ID为TextViewnew ArrayAdapter(this,R.layout.mytextview,R.ID.tview,this.file)这应该可以修复该异常。我想你的意思是(this.file是我的itemList)。为什么ListView中没有分隔符或线?如何创建它?谢谢
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tview"
android:textColor="@color/yourColor"
android:padding="5sp"
android:layout_width="fill_parent"
android:background="@drawable/rectgrad"
android:singleLine="true"
android:gravity="center"
android:layout_height="fill_parent"/>
ArrayAdapter<string> adapter = new ArrayAdapter<string>(this, R.layout.mytextview, itemlist);