- Forum posts: 1
Jul 15, 2014, 11:17:16 AM via Website
Jul 15, 2014 11:17:16 AM via Website
Help me with this simple piece of code...
Hey everyone, I got some problem learning android developement at the moment. I'm newbie, so bare with me
I'm currently following a guide at Androids own website. In one instance they're giving me the following code:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- the theme applied to the application or activity -->
<style name="CustomActionBarTheme"
parent="@style/Theme.AppCompat">
<item name="android:actionBarStyle">@style/MyActionBar</item>
<item name="android:actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="android:actionMenuTextColor">@color/actionbar_text</item>
<!-- Support library compatibility -->
<item name="actionBarStyle">@style/MyActionBar</item>
<item name="actionBarTabTextStyle">@style/MyActionBarTabText</item>
<item name="actionMenuTextColor">@color/actionbar_text</item>
</style>
<!-- ActionBar styles -->
<style name="MyActionBar"
parent="@style/Widget.AppCompat.ActionBar">
<item name="android:titleTextStyle">@style/MyActionBarTitleText</item>
<!-- Support library compatibility -->
<item name="titleTextStyle">@style/MyActionBarTitleText</item>
</style>
<!-- ActionBar title text -->
<style name="MyActionBarTitleText"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="android:textColor">@color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
<!-- ActionBar tabs text -->
<style name="MyActionBarTabText"
parent="@style/Widget.AppCompat.ActionBar.TabText">
<item name="android:textColor">@color/actionbar_text</item>
<!-- The textColor property is backward compatible with the Support Library -->
</style>
</resources>
As you may see, the code is about changing the style in the action bar..
I got some question regarding this code..
1.
I've wrote it down in my application aswell but it's not working on my virtual android machine - "unfortently, My first app has stopped working" (Name of the app is My first app). What could i possible be doing wrong?
2.
Now, what does the following code do:
parent="@style/Theme.AppCompat"
I know what a inheritance is, but what's going on here? What is Theme.AppCompat, were can i find the attributes?
3.
And this code:
<style name="MyActionBarTitleText"
parent="@style/TextAppearance.AppCompat.Widget.ActionBar.Title">
Basically, I wonder were all the data from the parents are located. Just like question 2
Hopefully You understand me!
Help would be really appreciated!
Recommended editorial content
With your consent, external content is loaded here.
By clicking on the button above, you agree that external content may be displayed to you. Personal data may be transmitted to third-party providers in the process. You can find more information about this in our Privacy Policy.