umgewandelt werden Ich habe mein Eclipse-Projekt in Android Studio-Projekt konvertiert und wenn ich die App ausführen, erhalte ich die folgende Ausnahme:
java.lang.ClassCastException: android.widget.LinearLayout$LayoutParams cannot be cast to com.android.internal.widget.ActionBarOverlayLayout$LayoutParams
at com.android.internal.widget.ActionBarOverlayLayout.applyInsets(ActionBarOverlayLayout.java:172)
at com.android.internal.widget.ActionBarOverlayLayout.onMeasure(ActionBarOverlayLayout.java:317)
at android.view.View.measure(View.java:16497)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
at android.view.View.measure(View.java:16497)
at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1912)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1109)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1291)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
at android.view.Choreographer.doCallbacks(Choreographer.java:574)
at android.view.Choreographer.doFrame(Choreographer.java:544)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
Mein Thema ist:
<style name="AppBaseTheme" parent="Theme.AppCompat" />
<!-- Application theme. -->
<style name="AppTheme" parent="AppBaseTheme">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/primary</item>
<item name="colorPrimaryDark">@color/primary_dark</item>
<item name="colorAccent">@color/accent</item>
<item name="android:textColorPrimary">@color/primary_text</item>
</style>
Meine Tätigkeit ist AppCompactActivity
und das Layout erstreckt:
<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"
android:fitsSystemWindows="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/toolbar" />
<!-- Your normal content view -->
<FrameLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<!-- <include layout="@layout/toolbar" /> -->
<FrameLayout
android:id="@+id/frag_container"
android:layout_width="match_parent"
android:layout_height="match_parent"></FrameLayout>
<!-- The navigation drawer -->
</LinearLayout>
<View
android:layout_width="match_parent"
android:layout_height="5dp"
android:background="@drawable/toolbar_shadow" />
</FrameLayout>
</LinearLayout>
<!-- Your drawer view. This can be any view, LinearLayout -->
<!-- is just an example. As we have set fitSystemWindows=true -->
<!-- this will be displayed under the status bar. -->
<LinearLayout
android:id="@+id/drawer_view"
android:layout_width="304dp"
android:layout_height="match_parent"
android:layout_gravity="left|start"
android:fitsSystemWindows="true">
<!-- Your drawer content -->
<ListView
android:id="@+id/left_drawer"
style="@style/NavDrawer"
android:layout_width="320dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:background="@color/icons"
android:choiceMode="singleChoice"
android:divider="@color/divider"
android:dividerHeight="0dp"
android:listSelector="@drawable/drawer_listview_background_selector" />
</LinearLayout>
</android.support.v4.widget.DrawerLayout>
Bitte beachten Sie, dass ich folgende Elemente im Thema enthalten sind, nach dem this SO thread
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
Das Projekt hat folgende Abhängigkeiten zu lesen:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.navasmdc:MaterialDesign:[email protected]'
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:cardview-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.wrapp.floatlabelededittext:library:0.0.6'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.github.flavienlaurent.datetimepicker:library:0.0.2'
compile('com.mikepenz.materialdrawer:library:[email protected]') {
transitive = true
}
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.anjlab.android.iab.v3:library:[email protected]'
compile 'com.github.alamkanak:android-week-view:1.2.1'
compile 'com.github.johnkil.android-robototextview:robototextview:2.4.0'
// AboutLibraries Library
compile('com.mikepenz.aboutlibraries:library:[email protected]') {
transitive = true
}
// ChangeLog Libraries
compile 'com.github.gabrielemariotti.changeloglib:library:1.5.2'
compile files('libs/universal-image-loader-1.9.3-with-sources.jar')
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.twotoasters.SectionCursorAdapter:library:1.0.+'
compile 'com.larswerkman:HoloColorPicker:1.5'
compile('com.crashlytics.sdk.android:crashlytics:[email protected]') {
transitive = true;
}
}
Sind Sie mit CyanogenMod? –
@ChrisBanes Nein, ich teste am GenyMotion Emulator. –
Auch das Projekt funktioniert, wenn ich es von Eclipse IDE aus ausführen. –