android.widget.ProgressBar无法强制转换为android.widget.LinearLayout

Kat*_*lon 3 android android-linearlayout progress-bar

GIVEN

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context=".InboxActivity" >

    <!-- refresh button -->

    <Button
        android:id="@+id/button_refresh_inbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentLeft="true"
        android:layout_alignParentTop="true"
        android:onClick="refreshInbox"
        android:text="@string/refresh_inbox" />

    <LinearLayout
        android:id="@+id/inbox_container"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/button_refresh_inbox" >

        <ProgressBar
            android:id="@+id/inbox_prog_bar"
            style="@android:style/Widget.ProgressBar.Small"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />
    </LinearLayout>

    <TextView
        android:id="@+id/empty_inbox"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@id/inbox_container"
        android:textIsSelectable="false" />

</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)

结果:

当我运行应用程序时,我收到错误

E/AndroidRuntime(930): java.lang.ClassCastException: android.widget.ProgressBar
cannot be cast to android.widget.LinearLayout
Run Code Online (Sandbox Code Playgroud)

有谁知道如何解决这一问题?

目标:

收件箱正在加载时显示进度条; 然后让收件箱内容填充线性布局.

背景:

一切都很好.我只是认为在加载收件箱时有一个进度条而不是空白屏幕会更好.添加进度条会导致错误.(我真的想在布局文件中指定进度条,而不是以编程方式).

jos*_*das 9

刷新和项目>清理您的项目.

这与自动生成R引用时所做的一些混乱有关,当清理它时将创建一个具有正确id引用的新的引用.