JonSkeet 2013-03-19 08:38 采纳率: 0%
浏览 2165
已采纳

表格行中的 Relative layout 布局

我在表格行中设置了相对布局,当运行下面的代码时出现 Logcat:错误,如何处理这个问题?

 <TableLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:background="#e3e1e1">
           <TableRow
           android:layout_width="fill_parent"
           android:layout_height="fill_parent">
                <RelativeLayout
                   android:layout_width="wrap_content"
                   android:layout_height="wrap_content">
                    <ProgressBar
                        android:id="@+id/tPr"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content" 
                        android:layout_centerInParent="true"/>
                   <GridView
                       android:id="@+id/tApps"
                       android:layout_width="wrap_content"
                       android:layout_height="258dp"
                       android:background="#e3e1e1"
                       android:gravity="center"
                       android:horizontalSpacing="2dp"
                       android:numColumns="3"
                       android:verticalSpacing="2dp"
                       android:visibility="gone">
                   </GridView>
               </RelativeLayout>
       </TableRow>
   </TableLayout>

Logcat:

02-20 17:34:34.261: E/AndroidRuntime(1125): FATAL EXCEPTION: main
02-20 17:34:34.261: E/AndroidRuntime(1125): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.coverflow/com.example.coverflow.CoverFlowExample}: java.lang.ClassCastException: android.widget.ProgressBar
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.os.Looper.loop(Looper.java:123)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at android.app.ActivityThread.main(ActivityThread.java:4627)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at java.lang.reflect.Method.invokeNative(Native Method)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at java.lang.reflect.Method.invoke(Method.java:521)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-20 17:34:34.261: E/AndroidRuntime(1125):     at dalvik.system.NativeStart.main(Native Method)
02-20 17:34:34.261: E/AndroidRuntime(1125): Caused by: java.lang.ClassCastException: android.widget.ProgressBar
02-20 17:34:34.261: E/AndroidRuntime(1125):     at com.example.coverflow.CoverFlowExample.onCreate(CoverFlowExample.java:41)

Line 41 是: top = (GridView)findViewById(R.id.tApps);

  • 写回答

3条回答 默认 最新

  • nana4ever 2013-03-25 06:17
    关注

    以前我也遇见过这个错误,由于不同的 View,在有 GridView 的地方,会扰乱一个 ProgressBar。应该清除你的项目。
    Project-->Clean...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器