java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to android.widget.FrameLayout -
aim : removing framelayout screen
logcat :
04-05 09:19:44.915: e/androidruntime(26483): fatal exception: main 04-05 09:19:44.915: e/androidruntime(26483): //java.lang.classcastexception: android.widget.linearlayout$layoutparams cannot cast android.widget.framelayout$layoutparams 04-05 09:19:44.915: e/androidruntime(26483): @ android.widget.framelayout.onmeasure(framelayout.java:311) 04-05 09:19:44.915: e/androidruntime(26483): @ android.view.view.measure(view.java:15775) 04-05 09:19:44.915: e/androidruntime(26483): @ .. android.widget.linearlayout.measurechildbeforelayout(linearlayout.java:1411) 04-05 09:19:44.915: e/androidruntime(26483): @ android.widget.linearlayout.measurevertical(linearlayout.java:698) 04-05 09:19:44.915: e/androidruntime(26483): @ android.widget.linearlayout.onmeasure(linearlayout.java:588) 04-05 09:19:44.915: e/androidruntime(26483): @ android.view.view.measure(view.java:15775) 04-05 09:19:44.915: e/androidruntime(26483): @ android.support.v4.widget.drawerlayout.onmeasure(drawerlayout.java:651)<-------- // think problem drawerlayout 04-05 09:19:44.915: e/androidruntime(26483): //at android.view.view.measure(view.java:15775) 04-05 09:19:44.915: e/androidruntime(26483): //at
main_activity.xml
<android.support.v4.widget.drawerlayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/drawer_layout" android:layout_width="match_parent" android:layout_height="match_parent"> <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:weightsum="2" android:orientation="vertical" > <linearlayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" > <framelayout android:id="@+id/frame_container_slider" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> </linearlayout> <!-- framelayout display fragments --> <framelayout android:id="@+id/frame_container" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" /> </linearlayout> <!-- listview display slider menu --> <listview android:id="@+id/list_slidermenu" android:layout_width="240dp" android:layout_height="match_parent" android:layout_gravity="start" android:choicemode="singlechoice" android:divider="@color/list_divider" android:dividerheight="1dp" android:listselector="@drawable/list_selector" android:background="@color/list_background"/>
mainactivity.java :
if(position!=0){ linearlayout.layoutparams lp = new linearlayout.layoutparams(0,0,0); // framelayout child of linearlayout getsupportfragmentmanager().findfragmentbyid(r.id.frame_container_slider).getview().setlayoutparams(lp); }
please change main activity code bellow code.
if (position != 0) { framelayout.layoutparams lp = new framelayout.layoutparams(0,0,0); getsupportfragmentmanager().findfragmentbyid(r.id.frame_container_slider) .getview() .setlayoutparams(lp); }
Comments
Post a Comment