這是一個示例代碼,你可以爲你的
AndroidMultiChoiceListActivity改變的.java
import android.app.Activity;
import android.os.Bundle;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class AndroidMultiChoiceListActivity extends Activity {
ListView choiceList;
String[] choice = { "Choice A",
"Choice B", "Choice C", "Choice D", "Choice E"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
choiceList = (ListView)findViewById(R.id.list);
ArrayAdapter<String> adapter
= new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_multiple_choice,
choice);
choiceList.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
choiceList.setAdapter(adapter);
}
}
main.xml中
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
android:textColor="#334422"
/>
<ListView
android:id="@+id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
在你的TextView使用android:textColor="#334422"
改變文本的顏色。
更改顏色作爲您的願望 – Aerrow
我已經實施了它..但我需要定製它..仔細閱讀問題 – NullPointerException
在哪裏你改變文本顏色,在XML任何活動? – Aerrow