I create a custom class and it extends FloatingActionButton
public class customFAB extends FloatingActionButton
{
public customFAB(Context context)
{
super(context);
}
}
I call this class from MainActivity
customFAB cFab = new customFAB(getApplicationContext);
But I get this error
You need to use a Theme.AppCompat theme (or descendant) with the design library.
my style.xml
is
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" />
</resources>
theme is Theme.AppCompat
. so what is the problem ?
Thanks.
Your
Application
'sContext
will not have a theme on it, despite the fact that you may set your app's default theme by using thetheme
attribute on the<application>
element in your manifest. You need to use yourActivity
'sContext
when instantiatingView
s like that.For example: