android.view.ViewGroup$LayoutParams cannot be cast to android.widget.TableRow$LayoutParams

02-24 03:18:22.859: E/AndroidRuntime(2992): FATAL EXCEPTION: main
02-24 03:18:22.859: E/AndroidRuntime(2992): java.lang.ClassCastException: android.view.ViewGroup$LayoutParams cannot be cast to android.widget.TableRow$LayoutParams
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.TableRow.mapIndexAndColumns(TableRow.java:164)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.TableRow.getVirtualChildCount(TableRow.java:149)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.TableRow.getColumnsWidths(TableRow.java:289)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.TableLayout.findLargestCells(TableLayout.java:508)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.TableLayout.measureVertical(TableLayout.java:473)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.TableLayout.onMeasure(TableLayout.java:439)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.View.measure(View.java:15848)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.View.measure(View.java:15848)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.View.measure(View.java:15848)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.View.measure(View.java:15848)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5012)
02-24 03:18:22.859: E/AndroidRuntime(2992): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)

02-24 03:18:22.859: E/AndroidRuntime(2992): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2189)

出错代码:

mPager = (ViewPager) findViewById(R.id.vPager);
//获取屏幕像素相关信息   
DisplayMetrics dm = new DisplayMetrics();      
getWindowManager().getDefaultDisplay().getMetrics(dm);    
//根据屏幕信息设置ViewPager广告容器的宽高  
mPager.setLayoutParams(new LayoutParams(dm.widthPixels-120, dm.heightPixels));  

解决办法:ViewPager需要设置在LinearLayout布局中,并且代码如下

mPager = (ViewPager) findViewById(R.id.vPager);
DisplayMetrics dm = new DisplayMetrics();      
getWindowManager().getDefaultDisplay().getMetrics(dm);    
//根据屏幕信息设置ViewPager广告容器的宽高  
mPager.setLayoutParams(new LinearLayout.LayoutParams(dm.widthPixels-120, dm.heightPixels));   

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值