【问题标题】:got error like error: Error: No resource found that matches the given name (at 'id' with value '@id/ surface_view')得到类似错误的错误:错误:找不到与给定名称匹配的资源(在“id”处,值为“@id/surface_view”)
【发布时间】:2014-07-13 19:25:27
【问题描述】:

activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:orientation="horizontal"  android:layout_width="fill_parent" android:layout_height="74.0dip"
     xmlns:android="http://schemas.android.com/apk/res/android">
     <io.vov.vitamio.widget.CenterLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content">

         <io.vov.vitamio.widget.VideoView android:id="@id/surface_view" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" android:layout_centerVertical="true" />


     </io.vov.vitamio.widget.CenterLayout>


  </RelativeLayout>

mediaconroller.xml

<RelativeLayout android:orientation="horizontal" android:background="@drawable/mediacontroller_bg" android:layout_width="fill_parent" android:layout_height="74.0dip" android:layout_marginLeft="0.0dip" android:layout_marginRight="0.0dip" android:layout_marginBottom="0.0dip" android:layout_alignParentBottom="true"
  xmlns:android="http://schemas.android.com/apk/res/android">
    <ImageButton android:gravity="center" android:id="@id/mediacontroller_play_pause" android:background="#00000000" android:layout_width="54.599976dip" android:layout_height="32.0dip" android:layout_marginRight="7.0dip" android:src="@drawable/mediacontroller_pause_button" android:layout_alignParentRight="true" android:layout_centerHorizontal="true" android:layout_centerVertical="true" android:contentDescription="@string/mediacontroller_play_pause" />
    <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_marginLeft="7.0dip" android:layout_marginTop="2.0dip" android:layout_marginRight="7.0dip" android:layout_marginBottom="2.0dip" android:layout_toLeftOf="@id/mediacontroller_play_pause">
        <RelativeLayout android:layout_width="fill_parent" android:layout_height="wrap_content">
            <TextView android:id="@id/mediacontroller_time_current" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_alignParentTop="true" style="@style/MediaController_Text" />
            <TextView android:id="@id/mediacontroller_time_total" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignParentTop="true" android:layout_alignParentRight="true" style="@style/MediaController_Text" />
        </RelativeLayout>
        <SeekBar android:id="@id/mediacontroller_seekbar" android:focusable="true" android:layout_width="fill_parent" android:layout_height="wrap_content" android:max="1000" android:layout_centerVertical="true" style="@style/MediaController_SeekBar" />
        <TextView android:ellipsize="marquee" android:id="@id/mediacontroller_file_name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:singleLine="true" android:layout_alignParentBottom="true" style="@style/MediaController_Text" />
    </RelativeLayout>
</RelativeLayout>

我在 res/drawable 文件夹中有四个文件,它们具有以下名称

mediacontroller_pause_button.xml
mediacontroller_play_button.xml 
mediacontroller_seekbar_thumb.xml
mediacontroller_seekbar.xml

id 不会自动更新我如何更新 id ? 我是 android 新手,请帮我解决这个错误我在关注两个布局文件 mediacontroller.xml 和 activity_main.xml 时出错 错误是

error: Error: No resource found that matches the given name (at 'id' with value '@id/ mediacontroller_time_current').

我没有使用 +id 符号,但问题是 R.java 不会自动更新它的 id 这就是为什么我没有收到建议我的问题是如何获得建议以便解决我的错误

【问题讨论】:

    标签: android stream video-streaming android-mediaplayer vitamio


    【解决方案1】:

    您可能想改用android:id="@+id/surface_view"

    基本上,“加号”表示您正在定义一个新的内联 id。如果您不添加它,那么您将添加对 id 的引用,该引用必须是预先存在的。

    例如,在android:layout_toLeftOf="@id/mediacontroller_play_pause" 中省略“+”是正确的,因为您没有在其中定义该 id。

    【讨论】:

    • 我没有使用 + 号,但问题是 R.java 不会自动更新它的 id 这就是为什么我没有收到建议我的问题是如何获得建议以便解决我的错误
    • @user3578882 我不确定我是否理解您要执行的操作。要引用可绘制对象,您必须使用@drawable/name,而不是@id/name。但是你不能使一个可绘制的文本视图的 id
    猜你喜欢
    • 1970-01-01
    • 2020-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-11-23
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    相关资源
    最近更新 更多