如何更改Android的默认的ListView的文本的颜色? [英] how to change the color of the text of the default ListView in android?

查看:289
本文介绍了如何更改Android的默认的ListView的文本的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有发言权的Andr​​oid默认的ListView android.R.layout.simple_list_item_1 。在这具有背景色黑色和列表的文本为白色。ListView控件

I have a default ListView from android say android.R.layout.simple_list_item_1.In which ListView having the background color black and text of the list is white.

现在我已经改变了的ListView白的背景色。于是在ListView中的文本poputating是白色默认情况下也。这就是为什么在ListView的数据是不可见的。

Now i have changed the background color of the ListView to White. So the text poputating on the listView are also of white color by default. That's why the data of the ListView are not visible.

这是填充在ListView中的文本是数组列表。那么,我设置的ListView的文本的颜色?我想改变的文字颜色填充的的ListView

The text which are populating on the ListView is the arraylist. So where I set the color of the text of ListView?? I want to change the Text color populated on the ListView.

谁能告诉是否有可能没有定制的ListView。

Can anybody tell whether it is possible without custom ListView.

推荐答案

回答 @ Archie.bpgc 是正确的。通过 此链接 ,这将有助于您了解什么是要完成。

Answer by @Archie.bpgc is right. Go Through This Link that will help you understand what is to be Done.

让我试着解释一下:

这里是你的列表适配器:

here is your list adapter :

String Values [] = {"value 1","Value 2"......}
YourlistAdapter = new ArrayAdapter  
      (this, R.layout.listlayout, R.id.listTextView,Values);
YourListView.setAdapter( listAdapter );`

R.layout.listlayout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<TextView
    android:id="@+id/listTextView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:textColor="your_color"
    android:text="TextView" />

现在我希望你明白。结果
R.layout.listlayout 是你的列表视图布局。结果
listTextView 里面的文本视图的ID布局上的文字被写。结果
价值观是内容的字符串数组要在列表视图中写

Now i hope you understood.
R.layout.listlayout is your layout for list view.
listTextView is the id of the text view inside the lay out on which your text is to be written.
Values are the string array of the content you want to write on list view

这篇关于如何更改Android的默认的ListView的文本的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆