I am having the most frustrating issue with a new Activity. I created it in the "normal" way:
Right-Click -> New -> Activity -> Empty Activity
However I am getting this annoying error when I try to launch the activity:
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.
I feel my question is different from the others on StackOverflow because I've done some poking around on StackOverflow as well as googling in general, but these errors seem to pop up when somebody tries to open a dialog box, not when they are simply trying to launch a new activity.
Here is my Activity Class ViewAllStudents.java:
public class ViewAllStudents extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_all_students);
}
}
I am getting the error on the setContentView(R.layout.activity_view_all_students);
line.
My layout resource file activity_view_all_students.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/view_all_students_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<include layout="@layout/student_table_header" />
<ListView
android:id="@+id/student_row"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
My include file student_table_header.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:background="@color/DARKOLIVEGREEN"
xmlns:android="http://schemas.android.com/apk/res/android">
<TextView
android:id="@+id/student_number_header"
style="@style/StdTableHeader"
android:layout_weight="1"
android:text="@string/student_number_header"/>
<TextView
android:id="@+id/student_id_header"
style="@style/StdTableHeader"
android:text="@string/student_id_header"/>
<TextView
android:id="@+id/student_location_header"
style="@style/StdTableHeader"
android:text="@string/student_location_header"/>
<TextView
android:id="@+id/student_status_header"
style="@style/StdTableHeader"
android:text="@string/student_status_header"/>
<TextView
android:id="@+id/student_delete_header"
style="@style/StdTableHeader"
android:text="@string/student_injuries_header"/>
<TextView
android:id="@+id/student_deleted_header"
style="@style/StdTableHeader"
android:text="@string/student_deleted_header"/>
<TextView
android:id="@+id/student_last_modified"
style="@style/StdTableHeader"
android:text="@string/student_last_modified_header"/>
</LinearLayout>
Finally, my styles resource file styles.xml:
<resources>
<style name="StdTableHeader">
<item name="android:textSize">14sp</item>
<item name="android:paddingLeft">4dp</item>
<item name="android:paddingRight">4dp</item>
<item name="android:paddingTop">2dp</item>
<item name="android:paddingBottom">2dp</item>
<item name="android:layout_weight">10</item>
<item name="android:layout_width">0dp</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:textColor">@color/WHITE</item>
<item name="android:textStyle">bold</item>
<item name="android:textAllCaps">true</item>
<item name="android:gravity">center</item>
</style>
</resources>
My AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="my.package">
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:supportsRtl="true">
<activity
android:name=".main.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan|stateHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".forms.formOne"
android:label="@string/form_one_header"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".forms.formTwo"
android:label="@string/form_two_header"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".forms.formThree"
android:label="@string/form_three_header"
android:theme="@style/AppTheme.NoActionBar"
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".main.AddStudent"
android:label="@string/title_activity_add_patient"
android:theme="@style/AppTheme.NoActionBar" />
<activity android:name=".main.ViewAllStudents"></activity>
</application>
</manifest>