You need to use a Theme.AppCompat theme (or descendant) with this activity

前端 未结 30 3989
感动是毒
感动是毒 2020-11-21 04:42

Android Studio 0.4.5

Android documentation for creating custom dialog boxes: http://developer.android.com/guide/topics/ui/dialogs.html

If you want a custom d

相关标签:
30条回答
  • 2020-11-21 05:03

    This is what fixed it for me: instead of specifying the theme in manifest, I defined it in onCreate for each activity that extends ActionBarActivity:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        setTheme(R.style.MyAppTheme);
        super.onCreate(savedInstanceState);
        setContentView(R.layout.my_activity_layout);
    ...
    }
    

    Here MyAppTheme is a descendant of Theme.AppCompat, and is defined in xml. Note that the theme must be set before super.onCreate and setContentView.

    0 讨论(0)
  • 2020-11-21 05:05

    I had this problem as well and what I did to fix it, AND still use the Holo theme was to take these steps:

    first I replaced this import:

    import android.support.v7.app.AppCompatActivity;
    

    with this one:

    import android.app.Activity;
    

    then changed my extension from:

    public class MyClass extends AppCompatActivity {//...
    

    to this:

    public class MyClass extends Activity {//...
    

    And also had to change this import:

    import android.support.v7.app.AlertDialog;
    

    to this import:

    import android.app.AlertDialog;
    

    and then you can use your theme tag in the manifest at the activity level:

    android:theme="@android:style/Theme.Holo.Dialog" />
    

    and lastly, (unless you have other classes in your project that has to use v7 appCompat) you can either clean and rebuild your project or delete this entry in the gradle build file at the app level:

    compile 'com.android.support:appcompat-v7:23.2.1'
    

    if you have other classes in your project that has to use v7 appCompat then just clean and rebuild the project.

    0 讨论(0)
  • 2020-11-21 05:05

    Change your theme style parent to

     parent="Theme.AppCompat"
    

    This worked for me ...

    0 讨论(0)
  • 2020-11-21 05:06

    All you need to do is add android:theme="@style/Theme.AppCompat.Light" to your application tag in the AndroidManifest.xml file.

    0 讨论(0)
  • 2020-11-21 05:06

    for me was solution to use ContextThemeWrapper:

    private FloatingActionButton getFAB() {
    Context context = new android.support.v7.view.ContextThemeWrapper(getContext(), R.style.AppTheme);
    FloatingActionButton fab = new FloatingActionButton(context);
    return fab;}
    

    from Android - How to create FAB programmatically?

    0 讨论(0)
  • 2020-11-21 05:07

    In my case such issue was appear when i tried to show Dialog. The problem was in context, I've use getBaseContext() which theoretically should return Activity context, but appears its not, or it return context before any Theme applied.

    So I just replaced getBaseContexts() with "this", and now it work as expected.

            Dialog.showAlert(this, title, message,....);
    
    0 讨论(0)
提交回复
热议问题