I have some strange issues:
I added the MediaRouteButton in my Layout
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/group_right"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/right_btns"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:minWidth="@dimen/actionbar_icon_width"
android:orientation="horizontal" >
</LinearLayout>
<android.support.v7.app.MediaRouteButton
android:id="@+id/media_route_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
It works really fine on my newer devices. But for older devices with 3.1, 2.3 or lower I'm getting this exception
Caused by: android.view.InflateException: Binary XML file line #74: Error inflating class android.support.v7.app.MediaRouteButton
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.rInflate(LayoutInflater.java:727)
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 de.myapp.views.MyActionBar.<init>(MyActionBar.java:54)
... 36 more
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)
... 43 more
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x7f01000c a=3}
at android.content.res.Resources.loadDrawable(Resources.java:1841)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.<init>(View.java:2462)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:121)
at android.support.v7.app.MediaRouteButton.<init>(MediaRouteButton.java:117)
... 46 more
In my code it happens when I inflate the xml Layout
public MyActionBar(Context context, AttributeSet attrs) {
super(context, attrs);
inflate(context, R.layout.group_action_bar, this);
titleGroup = (ViewGroup) findViewById(R.id.group_title);
leftBtnGroup = (ViewGroup) findViewById(R.id.left_btns);
rightBtnGroup = (ViewGroup) findViewById(R.id.right_btns);
titleAppendix = findViewById(R.id.group_title_appendix);
}
Does anyone know why this doesn't work for older devices with lower api-level?
Thanks!!!