目的:
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 be cast to android.widget.FrameLayout$LayoutParams
04-05 09:19:44.915: E/AndroidRuntime(26483): at android.widget.FrameLayout.onMeasure(FrameLayout.java:311)
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 ..
android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1411)
04-05 09:19:44.915: E/AndroidRuntime(26483): at android.widget.LinearLayout.measureVertical(LinearLayout.java:698)
04-05 09:19:44.915: E/AndroidRuntime(26483): at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
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 android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:651)<-------- // i think the problem is 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
:某些屏幕
logcat的拆卸的FrameLayout 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 to display Fragments -->
<FrameLayout
android:id="@+id/frame_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
</LinearLayout>
<!-- Listview to 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 is child of linearlayout
getSupportFragmentManager().findFragmentById(R.id.frame_container_slider).getView().setLayoutParams(lp);
}
他們說,日誌不給的問題的根源.. – TheLostMind
檢查進口 – Raghunandan
@Raghunandan什麼問題? import android.support.v4.app.ActionBarDrawerToggle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.widget.DrawerLayout; import android.widget.AdapterView; import android.widget.FrameLayout; – Abdellah