【问题标题】:Error inflating class android.support.v7.app.MediaRouteButton膨胀类 android.support.v7.app.MediaRouteButton 时出错
【发布时间】:2014-02-23 07:26:08
【问题描述】:

我已将 android-support-v7-appcompat,android-support-v7-mediarouter 库项目添加到构建路径。

以下是我的主要活动,导入按钮没有错误,但是在执行应用程序时,会发生错误膨胀 MediaRouteButton。 非常感谢您的任何建议!

<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;

【问题讨论】:

  • android.support.v7.app.MediaRouteButton 更正第一个android.support.v7.app.MediaRouteButton`` 从'android.support.v7.app.MediaRouteButton'中删除单引号

标签: android google-cast chromecast


【解决方案1】:

首先你应该替换这个

<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>

<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>

更新:你必须先appcompat referecning。将 appcompat 库添加到您的按照步骤Right Click Project--&gt; go to properties--&gt; android ---&gt; ib tab 添加 appcompat 项目。

【讨论】:

  • 对不起,这是编辑问题时的书写错误。事实上 MediaRouteButton 并没有这样的错误。 Ecllipse 将检测到此类错误并提供建议。我的项目中没有构建错误/问题。
  • @cc5zhenhua 是否正确引用了appcompat?
  • 是的。我尝试将项目添加到 java 构建路径、android 项目首选项但不工作。仍在我项目中错过的任何地方徘徊。
  • 终于得到解决方案。这真的是我的 appcompat 问题。应该是 Project--properties--android---lib 选项卡来添加 appcompat 项目。一开始我只是将它们添加到构建路径中。
  • @cc5zhenhua 那么如果它是一个 appcompat 引用问题,则发布的解决方案不能解决问题。你应该不接受这个答案
猜你喜欢
  • 2017-07-06
  • 2014-10-18
  • 2015-01-06
  • 2017-07-29
  • 2014-12-21
  • 1970-01-01
  • 2017-05-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多