Replacing the theme in the app

Hello!

I wanted to change the subject, which I did later,but not in the way I intended. As a result, the question remains, why do I not change the topic as it should change?

Here are the options that I tried to apply in order to change the theme in the program:

Option 1. "Insert the handles". Opening the file-Manifest.
And in this case, instead of "AppTheme " in this line, "android:theme="@style/AppTheme" >" we insert another topic. For example: "Theme.NoTitleBar.FullScreen". It will look like this: android:theme="@style/Theme.NoTitleBar.FullScreen".

Here is the original code:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 package="com.example.progect20"
 android:versionCode="1"
 android:versionName="1.0" >

 <uses-sdk
 android:minSdkVersion="8"
 android:targetSdkVersion="21" />

 <application
 android:allowBackup="true"
 android:theme="@style/AppTheme" >
 <activity
 android:name=".MainActivity"
 android:label="@string/app_name" >
 <intent-filter>
 <action android:name="android.intent.action.MAIN" />

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

</manifest>

Changing the line:

Option 1.1

"android:theme="@style/Theme.NoTitleBar.FullScreen"

Returns an error - Description Resource Path Location Typeerror: Error: No resource found that matches the given name (at 'theme' with value '@style/Theme.NoTitleBar.FullScreen'). AndroidManifest.xml /Progect20 line 11 Android AAPT Problem

Option 1.2

"android:theme="@android:style/Theme.NoTitleBar.FullScreen

Returns an error -

Description Resource Path Location Typeerror: Error: No resource found that matches the given name (at 'theme' with value '@android:style/Theme.NoTitleBar.FullScreen'). AndroidManifest.xml /Progect20 line 11 Android AAPT Problem

As I understand it, the error is due to the fact that the compiler does not find this topic in the resources.

Or you can do the same, but only with help tables, further avoiding errors:

Https://www.youtube.com/watch?v=q3uqbcxKb0o

After I supposedly installed a new theme, I try to run it on the emulator, and when the program starts, it crashes with the error "the application is stopped".

And here is the Errors log of the "virtual machine" in Eclipse:

 09-03 13:03:39.245: E/Trace(786):
 error opening trace file: No such file
 or directory (2) 09-03 13:03:39.595:
 E/AndroidRuntime(786): FATAL
 EXCEPTION: main 09-03 13:03:39.595:
 E/AndroidRuntime(786):
 java.lang.RuntimeException: Unable to
 start activity
 ComponentInfo{com.example.progect20/com.example.progect20.MainActivity}:
 java.lang.IllegalStateException: You
 need to use a Theme.AppCompat theme
 (or descendant) with this activity.
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.ActivityThread.access$600(ActivityThread.java:141)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.os.Handler.dispatchMessage(Handler.java:99)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.os.Looper.loop(Looper.java:137)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.ActivityThread.main(ActivityThread.java:5041)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 java.lang.reflect.Method.invokeNative(Native
 Method) 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 java.lang.reflect.Method.invoke(Method.java:511)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 dalvik.system.NativeStart.main(Native
 Method) 09-03 13:03:39.595:
 E/AndroidRuntime(786): Caused by:
 java.lang.IllegalStateException: You
 need to use a Theme.AppCompat theme
 (or descendant) with this activity.
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:110)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:99)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 com.example.progect20.MainActivity.onCreate(MainActivity.java:14)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.Activity.performCreate(Activity.java:5104)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): at
 android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
 09-03 13:03:39.595:
 E/AndroidRuntime(786): ... 11 more

Judging by the log, here we are told that we need to use themes related to AppCompat, or inherit from the AppCompat component. topics.

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

So that's why I get this error? Why exactly with AppCompat interaction should I use themes? Why can't they just be put in the standard way?

Thanks.

Author: Виталина, 2014-09-03

1 answers

Add values-v21 folder to RES and styles.xml with the code

<style name="Theme" parent="@style/Theme.Material.Light" >
 1
Author: sviter-pro, 2014-11-19 09:21:24