Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/196.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android XML布局中奇怪的id混淆_Android_Xml_Android Layout - Fatal编程技术网

Android XML布局中奇怪的id混淆

Android XML布局中奇怪的id混淆,android,xml,android-layout,Android,Xml,Android Layout,我遇到了一个奇怪的情况,android构建似乎在读取一个元素的id作为属于另一个元素 以下是相关的XML: <TextView android:layout_marginTop="30dp" android:id="@+id/tour_explanation" android:layout_height="wrap_content" android:layout_width="match_parent"

我遇到了一个奇怪的情况,android构建似乎在读取一个元素的id作为属于另一个元素

以下是相关的XML:

    <TextView 
        android:layout_marginTop="30dp"
        android:id="@+id/tour_explanation"
        android:layout_height="wrap_content"
        android:layout_width="match_parent"
        style="@android:style/TextAppearance.DeviceDefault.Large"/>
    <LinearLayout
            android:layout_height="0dp"
            android:layout_width="match_parent"
            android:id="@+id/audio_container"
            android:orientation="horizontal">
        </LinearLayout>
这就是错误:

((TextView)v.findViewById(R.id.tour_explanation)).setText(b.getString(ToursPagerAdapter.STATION_TEXT));
java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.TextView
出于某种原因,文本视图中的
id
与LinearLayout关联。我尝试了线性布局,有结束标记和没有结束标记——没有区别。如果我颠倒顺序,将TextView放在LinearLayout之后,错误就会消失


这是什么原因?如何让它消失?

清理您的项目(例如,project>Clean in Eclipse)。太棒了!非常感谢!