Error inflating class android.support.v7.app.MediaRouteButton

╄→尐↘猪︶ㄣ 提交于 2019-12-12 03:39:36

问题


I've added the android-support-v7-appcompat,android-support-v7-mediarouter library project to build path.

following are my main activity and no errors for import the button, but when execute the app, error inflating MediaRouteButton happens. Thanks a lot for any advice!

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="vertical" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
> 
<android.support.v7.app.MediaRouteButton
            android:id="@+id/castbutton"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_weight="2"
            >
</android.support.v7.app.MediaRouteButton>'

...

public class MainActivity extends android.support.v4.app.FragmentActivity 
        implements OnClickListener {
private android.support.v7.app.MediaRouteButton castbutton;

回答1:


First of all you should replace this

<android.support.v7.app.`MediaRouteButton`
        android:id="@+id/castbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        >
</android.support.v7.app.MediaRouteButton>

With

<android.support.v7.app.MediaRouteButton
        android:id="@+id/castbutton"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        >
</android.support.v7.app.MediaRouteButton>

Update: You must appcompat referecning first. To add appcompat library into your Follow the steps Right Click Project--> go to properties--> android ---> ib tab to add the appcompat project.



来源:https://stackoverflow.com/questions/21965402/error-inflating-class-android-support-v7-app-mediaroutebutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!