0
我想在android中爲我的文本設置顏色。每當我啓動我的應用程序,它都會關閉。以下是我在color.xml文件:試圖設置顏色到我的文本在android中
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<color name="background_color">#006400</color>
<color name="app_text_color">#FFE4C4</color>
以下是我在我的MainActivity類別:
int textColor = getResources().getColor(R.color.app_text_color);
TextView helloText = (TextView)findViewById(R.string.hello_world);
helloText.setTextColor(textColor);
這裏是佈局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<TextView
android:id="@+id/hello_world"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/hello_world"
/>
</RelativeLayout>
原木車:
04-17 21:00:39.290: E/AndroidRuntime(9986): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1670)
它仍然沒有出於某種原因,申請強制保持密切 –
粘貼您的XML佈局代碼 – stinepike
和logcat的數據也崩潰報告 – stinepike