2017-09-06 16 views
-1

登録フォームを開始するとすぐにダイアログボックスとして表示する必要があるアクティビティを作成しています。ただし、アクティビティは常にクラッシュします。 次の活動のためのコードである:ここでAndroidのダイアログボックスがクラッシュするApp

public class CheckInActivity extends AppCompatActivity{ 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_check_in); 
    getDialogue(); 



} 

public void getDialogue(){ 

    //Pop dialogue 

    AlertDialog.Builder mBuilder= new AlertDialog.Builder(getApplicationContext()); 
    View mView= getLayoutInflater().inflate(R.layout.dialog_register, null); 
    final EditText mPhone= (EditText) mView.findViewById(R.id.etPhone); 
    final EditText mPass= (EditText) mView.findViewById(R.id.etPass); 
    final EditText mRtPass= (EditText) mView.findViewById(R.id.etRtPass); 
    Button mRegisterButton = (Button) mView.findViewById(R.id.btnRegister); 


    mBuilder.setView(mView); 
    AlertDialog dialog= mBuilder.create(); 
    dialog.show(); 

} 
} 

はactivity_check_in.xmlファイルです:ここで

<?xml version="1.0" encoding="utf-8"?> 
<android.support.constraint.ConstraintLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.shashank_pc.trial.CheckInActivity"> 

</android.support.constraint.ConstraintLayout> 

活動がandroid_manifest.xmlファイルである

<activity android:name=".CheckInActivity" 
     android:theme="@style/Theme.AppCompat"> 

     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter> 

    </activity> 

エラーメッセージは次のとおりです。

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

助けてください!

答えて

0

ちょうど

android.support.v7.app.AlertDialog.Builder mBuilder= new android.support.v7.app.AlertDialog.Builder(getApplicationContext()); 

またはちょうどAndroidManifest.xmlファイルでアプリケーションタグにandroid:theme="@style/Theme.AppCompat.Light"を追加して

AlertDialog.Builder mBuilder= new AlertDialog.Builder(getApplicationContext()); 

この行を置き換えるAlertDialog.Builder mBuilder= new AlertDialog.Builder(this);

+0

これは質問に対する答えを提供しません。批評をしたり、著者の説明を求めるには、投稿の下にコメントを残してください。 - [レビューの投稿](レビュー/低品質の投稿/ 17255671) – FluffyKitten

0

を試してみてください。

+0

使用しないでください。まだクラッシュする – Thanatos

関連する問題