これは何度も尋ねられていますが、これまでにこの問題を解決しましたが、この時間がかかりました。これは1か所で動作していますが、アラートダイアログでアプリケーションがクラッシュする
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
私の登録クラスのコードは、ログインアクティビティ用に同じクラスが書かれています。
public class RegistrationActivity extends AppCompatActivity
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_registration);
if(sql_code.equalsIgnoreCase("0")){
String resultCode= command1.getString("result");
if(resultCode.equalsIgnoreCase("0")){
AlertDialog alertDialog = new AlertDialog.Builder(getApplicationContext()).create();
alertDialog.setTitle("Account Created");
alertDialog.setMessage("Account Created Successfully.");
alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent i= new Intent(RegistrationActivity.this, LoginActivity.class);
startActivity(i);
}
});
alertDialog.show();
マニフェストファイル
<activity
android:name=".ticketing.activities.checkout.RegistrationActivity"
android:screenOrientation="portrait"
android:label="@string/title_activity_registration"
android:theme="@style/AppTheme" />
Style.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:fontFamily">Roboto</item>
</style>
すべてが整備されているが、それでもその私に、このエラーメッセージを与えて、親切に私は何私を導いここで間違っている。
を、あなたは、「アクティビティ」に「AppCompatActivity」を変更してみてくださいことはできますか? –
[Androidカスタムダイアログ](http://stackoverflow.com/questions/5544405/android-custom-dialog)の可能な複製 –
可能な複製http://stackoverflow.com/questions/21814825/you-need-to-use -a-theme-appcompat-theme-or-descend-with-this-activity –