8

Hi everyone I am new to android ,

I get the following crash in the xml. as UnsupportedOperationException: Can't convert to color: type=0x2 in Galaxy tab 10.1.

android.view.InflateException: Binary XML file line #9: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:596)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:671)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
at com.test.colors.views.HUMCommentsView.<init>(HUMCommentsView.java:77)
at com.test.colors.views.HUMDialog.initUi(HUMDialog.java:73)
at com.test.colors.views.HUMDialog.<init>(HUMDialog.java:53)
at com.test.colors.views.HUMSocialView.initUi(HUMSocialView.java:124)
at com.test.colors.views.HUMSocialView.<init>(HUMSocialView.java:94)
at com.test.colors.fragments.HUMVideoDetailFragment.initUi(HUMVideoDetailFragment.java:235)
at   com.test.colors.fragments.HUMVideoDetailFragment.onCreateView(HUMVideoDetailFragment.java:151)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:1478)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:927)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1104)
at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:682)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1460)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:440)
at android.os.Handler.handleCallback(Handler.java:587)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4123)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:416)
at android.view.LayoutInflater.createView(LayoutInflater.java:576)
... 27 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to color: type=0x2
at android.content.res.TypedArray.getColor(TypedArray.java:326)
at android.widget.TextView.<init>(TextView.java:538)
at android.widget.TextView.<init>(TextView.java:480)
at com.test.colors.views.HUMTextView.<init>(HUMTextView.java:42)
... 30 more

This is my xml file

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:hummer="http://schemas.android.com/apk/res/com.test.colors"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:padding="@dimen/dm_cmnt_margin" >

<com.test.colors.views.HUMTextView
    android:id="@+id/cmmnt_txt_title"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:textColor="@color/clr_cmmnts"
    android:textSize="@dimen/sz_cmnt_header"
    hummer:font_type="@integer/fnt_cmnt_head" />

<com.test.colors.views.HUMEditText
    android:id="@+id/cmmnt_edt"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:background="@drawable/textholder_comments"
    android:ems="10"
    android:hint="@string/cmnt_add"
    android:padding="@dimen/dm_padding"
    android:textColor="@color/clr_cmmnts"
    android:imeOptions="actionDone"
     android:singleLine="true"
    android:textColorHint="@color/clr_cmmnts"
    hummer:font_type="@integer/fnt_cmnt_edittext" />

<ImageView
    android:id="@+id/cmmnt_divder"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/cmmnt_edt"
    android:layout_marginBottom="@dimen/dm_margin"
    android:layout_marginTop="@dimen/dm_margin"
    android:background="@drawable/divider" />

<ListView
    android:id="@+id/cmmnt_listview"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/cmmnt_divder"
    android:layout_margin="@dimen/dm_margin"
    android:background="@android:color/transparent"
    android:layout_marginBottom="@dimen/dm_cmnt_lv_margin"
    android:layout_marginTop="@dimen/dm_cmnt_lv_margin"
    android:divider="@drawable/divider" >
</ListView>

<com.test.colors.views.HUMTextView
    android:id="@+id/cmmnt_txt_empty"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_below="@+id/cmmnt_divder"
    android:layout_margin="@dimen/dm_margin"
    android:gravity="center"
    android:text="@string/cmnt_loading"
    android:textColor="@color/clr_desc"
    android:textSize="@dimen/sz_det_desc"
    android:visibility="gone"
    hummer:font_type="@integer/fnt_empty_txt" />

This is my color code used in colors.xml

<color name="clr_cmmnts">#999999</color>  

.Please help anyone...

It crashes in onCreate

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreateView(inflater, container, savedInstanceState);
        HUMUtils.Log("onCreateView");
        mRootView = inflater.inflate(R.layout.frag_video_detail, null);
        mContext = getActivity();       
        return mRootView;
    }

in line

mRootView = inflater.inflate(R.layout.frag_video_detail, null);

Crashes are found only in following devices

Galaxy Tab 7.0 Plus (GT-P6200) , Galaxy Tab 10.1 (GT-P7500), Galaxy Tab 8.9 (GT-P7300)

Works fine in other devices

4

0 回答 0