【发布时间】:2014-06-04 19:50:23
【问题描述】:
我想更改列表视图上的文本颜色,我发现我应该在 xml 中使用和 costumlayout 来完成。但是当我尝试它时,它使我的应用程序崩溃了。
这是我的活动:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/table_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical"
tools:context="com.example.wowquiz.Scoreboard"
tools:ignore="MergeRootFrame" >
<TextView
android:id="@+id/textView1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/abc_action_bar_title_text_size"
android:layout_marginTop="@dimen/abc_action_bar_title_text_size"
android:background="@drawable/vraagbackground"
android:gravity="center"
android:text="@string/highscore"
android:textColor="@color/white"
android:textSize="@dimen/sp" />
<RelativeLayout
android:id="@+id/list"
android:layout_width="wrap_content"
android:layout_height="244dp" >
<ListView
android:id="@+id/listViewScores"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_margin="@dimen/abc_action_bar_title_text_size"
android:background="@drawable/vraagbackground"
android:dividerHeight="1dp"
android:gravity="center"
android:textColor="@color/white" >
</ListView>
</RelativeLayout>
<Button
android:id="@+id/button1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="@dimen/abc_action_bar_title_text_size"
android:background="@drawable/restartbutton"
android:onClick="Back" />
这是我的.java
public void readScore() {
final List<String> scores = db.getScoreNames();
db.getMin();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
R.layout.Costumlayout, android.R.id.text1, scores);
final ListView listViewScores = (ListView) findViewById(R.id.listViewScores);
listViewScores.setAdapter(adapter);
}
这是我的 costumlayout.xml:
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/listTextView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
/>
我只希望颜色为白色以使其更具可读性。
提前致谢
【问题讨论】:
-
你看过logcat的输出了吗?
标签: android view android-activity