0
Android崩潰我遇到了一個特別奇怪的崩潰,關於長按EditText有一些文本(否則工作正常)。這系統地發生。在EditText長按
這裏是堆棧跟蹤:
android.content.res.Resources$NotFoundException: Resource is not a ColorStateList (color or path): TypedValue{t=0x2/d=0x1010036 a=3}
at android.content.res.Resources.loadColorStateList(Resources.java:3532)
at android.content.res.TypedArray.getColorStateList(TypedArray.java:343)
at android.widget.TextView.setTextAppearance(TextView.java:3149)
at android.support.v7.widget.AppCompatTextView.setTextAppearance(AppCompatTextView.java:56)
at android.support.v7.internal.widget.ActionBarContextView.initTitle(ActionBarContextView.java:139)
at android.support.v7.internal.widget.ActionBarContextView.setTitle(ActionBarContextView.java:115)
at android.support.v7.internal.view.StandaloneActionMode.setTitle(StandaloneActionMode.java:60)
at android.support.v7.internal.view.SupportActionModeWrapper.setTitle(SupportActionModeWrapper.java:63)
at android.widget.Editor$SelectionActionModeCallback.onCreateActionMode(Editor.java:3268)
at com.android.internal.policy.impl.PhoneWindow$DecorView$ActionModeCallbackWrapper.onCreateActionMode(PhoneWindow.java:3039)
at android.support.v7.internal.view.SupportActionModeWrapper$CallbackWrapper.onCreateActionMode(SupportActionModeWrapper.java:155)
at android.support.v7.app.AppCompatDelegateImplV7$ActionModeCallbackWrapperV7.onCreateActionMode(AppCompatDelegateImplV7.java:1644)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionModeFromWindow(AppCompatDelegateImplV7.java:748)
at android.support.v7.app.AppCompatDelegateImplV7.startSupportActionMode(AppCompatDelegateImplV7.java:642)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.startAsSupportActionMode(AppCompatDelegateImplV14.java:74)
at android.support.v7.app.AppCompatDelegateImplV14$AppCompatWindowCallbackV14.onWindowStartingActionMode(AppCompatDelegateImplV14.java:58)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionMode(PhoneWindow.java:2651)
at com.android.internal.policy.impl.PhoneWindow$DecorView.startActionModeForChild(PhoneWindow.java:2638)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
at android.view.ViewGroup.startActionModeForChild(ViewGroup.java:675)
at android.view.View.startActionMode(View.java:4756)
at android.widget.Editor.startSelectionActionMode(Editor.java:1831)
at android.widget.Editor.performLongClick(Editor.java:1060)
at android.widget.TextView.performLongClick(TextView.java:10149)
at android.view.View$CheckForLongPress.run(View.java:19433)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:146)
at android.app.ActivityThread.main(ActivityThread.java:5653)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1291)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1107)
at dalvik.system.NativeStart.main(Native Method)
我看到幾個帖子上的SO,但到目前爲止沒有運氣。我還必須提到,這發生在三星Galaxy Tab 3 API 19上,因爲它似乎有一些已經標記爲issues,但票證顯示爲固定。
這是給你一些代碼:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_login">
<Button
android:id="@+id/mServerUrlButton"
style="@style/OkButton"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="100dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="100dp"
android:layout_marginStart="30dp"
android:layout_marginTop="90dp"/>
<EditText
android:id="@+id/mServerUrlEditText"
style="@style/LoginField"
android:layout_width="500dp"
android:layout_marginTop="90dp"
android:layout_toLeftOf="@id/mServerUrlButton"
android:layout_toStartOf="@id/mServerUrlButton"
android:hint="@string/server_url_placeholder"
android:inputType="textUri"/>
</RelativeLayout>
而且styles.xml:
<style name="AppTheme" parent="AppTheme.Base"/>
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/green</item>
<item name="colorPrimaryDark">@color/green</item>
<item name="colorAccent">@color/green</item>
<item name="colorControlNormal">@color/black</item>
<item name="colorControlActivated">?attr/colorControlNormal</item>
<item name="colorControlHighlight">?attr/colorControlNormal</item>
<item name="android:textColorPrimary">?attr/colorControlNormal</item>
<item name="android:textColorSecondary">?attr/colorControlNormal</item>
<item name="android:windowContentOverlay">@null</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:fitsSystemWindows">true</item>
</style>
<style name="OkButton" parent="@android:style/Widget.Button">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">@dimen/confirm_button_height</item>
<item name="android:background">@drawable/bg_login_button</item>
<item name="android:text">@string/ok_button</item>
<item name="android:textColor">@color/white</item>
<item name="android:textSize">20sp</item>
<item name="android:paddingLeft">16dp</item>
<item name="android:paddingRight">16dp</item>
</style>
<style name="Field" parent="@android:style/Widget.EditText">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">match_parent</item>
<item name="android:background">@drawable/bg_login_field</item>
<item name="android:textColorHint">@color/black</item>
<item name="android:textSize">15sp</item>
<item name="android:padding">10dp</item>
<item name="android:gravity">top</item>
<item name="android:singleLine">true</item>
</style>
<style name="LoginField" parent="Field">
<item name="android:layout_width">@dimen/login_field_width</item>
<item name="android:layout_height">@dimen/login_field_height</item>
<item name="android:gravity">center_vertical</item>
</style>
這確實窮人都來自我的暗示顏色或背景的繪製我已經試圖逐個禁用它們以查看它失敗的位置。即使沒有任何定製(只需要寬度和高度),它仍然崩潰。
還在這裏是我的colors.xml:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="white">#FFFFFF</color>
<color name="black">#000000</color>
<color name="green">#015b27</color>
<color name="pink">#a10453</color>
<color name="gray">#707070</color>
<color name="light_gray">#B6B6B6</color>
<color name="light_green">#8AC97A</color>
<color name="light_pink">#FF84C2</color>
<color name="white_alpha">#DDFFFFFF</color>
<color name="black_alpha">#80000000</color>
</resources>
而且我繪製:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<corners android:radius="10dp" />
<solid android:color="@color/white" />
<stroke android:width="1dp" android:color="@color/black" />
</shape>
任何幫助將不勝感激! :)
[更改Android中的TextView的顏色(的可能重複http://stackoverflow.com/questions/19065870/changing-color-of-textview -in-android) – Buddy
可能是那樣,但我檢查了我的顏色,沒有錯。我以這種方式編輯我的帖子 – ptitvinou