相关疑难解决方法(0)

Android选择器和文本颜色

我想要一个简单TextView的运行方式simple_list_item_1ListView做.这是XML:

<TextView xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_height="wrap_content" android:layout_width="fill_parent"
    android:gravity="center" android:focusable="true"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:textAppearance="?android:attr/textAppearanceLarge"
    android:background="@android:drawable/list_selector_background" />
Run Code Online (Sandbox Code Playgroud)

一切都有效,除了(预期)在聚焦状态下不会改变的文本颜色.如何将其更改为textAppearanceLargeInverse

android textview android-selector

181
推荐指数
6
解决办法
25万
查看次数

android.content.res.Resources $ NotFoundException-/res/color/file.xml

我试图实现颜色状态列表资源在我的Android应用程序,以下Android开发者指南颜色状态列表资源| Android开发人员。因此,我在目录中创建了两个资源文件button_text.xmlbutton_background.xmlres/color/并在@color/button_text和中@color/button_background分别引用了它们activity_main.xml。这是布局代码

<Button
    android:id="@+id/myButton"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/app_name"
    android:layout_marginTop="150dp"
    android:layout_gravity="center"
    android:textColor="@color/button_text"
    android:background="@color/button_background"/>
Run Code Online (Sandbox Code Playgroud)

在运行该应用程序时,我Resources Not Found Exception在日志中得到如下所示:

Process: com.example.myanimation, PID: 29254
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.myanimation/com.example.myanimation.MainActivity}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class Button
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2659)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2724)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1473)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6123)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
at …
Run Code Online (Sandbox Code Playgroud)

java xml android android-resources android-color

2
推荐指数
1
解决办法
2837
查看次数