Reputation: 1711
I am using the current style and theme for my toolbar and using a support library. I am extending AppCompatActivity rather than the normal activity.
<style name="AppTheme" parent="Theme.AppCompat.DayNight.NoActionBar"> <item name="android:windowNoTitle">false</item>
<item name="android:windowActionBar">true</item>
</style>
I am getting the error and below is the stacktrace,
Process: com.random.simplenotes, PID: 2176
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:1916)
at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
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:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Application terminated.
Main Activity
The problem occurred when I tried to apply a Dark Theme.parent="Theme.AppCompat.DayNight.NoActionBar"
For this attribute how do I know which themes will work and which ones will not ? and what should be done to apply the dark theme which does not give any error ?
Let me know what else code is needed and I will edit the question accordingly.
EDIT 1 As requested in the comments, I have added the Activity onCreate() method
Initialization
DataBaseHelper dbhelper;
ListView notesView;
CustomCursor dataCursor;
int ROW_NUMBER;
Cursor passCursor;
Toolbar bar;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
dbhelper = new DataBaseHelper(this);
passCursor = dbhelper.fetchAllNotes();
dataCursor = new CustomCursor(this,passCursor);
notesView = (ListView)findViewById(R.id.listView);
notesView.setAdapter(dataCursor);
notesView.setOnItemClickListener(this);
bar = (Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(bar);
}
Upvotes: 1
Views: 133
Reputation: 2659
Remove the <item name="android:windowActionBar">true</item>
from your theme file if you are using a Toolbar
for a supportActionBar
Upvotes: 2