I am making an activity that has to display a registration form as a dialogue box as soon as it starts. However, the activity always crashes. The following is the code for the activity:
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();
}
}
Here is the activity_check_in.xml file:
<?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>
Here is the activity in the android_manifest.xml file
<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>
The error message is the following:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
Please help!!