• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Help me with this simple piece of code...

coinage23

Lurker
Jul 5, 2014
5
0
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>

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!
 
1. Learn how to use the Logcat function. it will save you thousands of questions and allow you to pinpoint your problems. 99% of the time it will point you right to the problematic line in your code and let you know what is wrong with it.

Also, I hate the AVd, its slow, doesnt work exactly like a phone and lacks many real world capabilities without adding additional functioning in. basically a phone or tab is quicker and easier. And most apps aren't dangerous to your phone, they will just close. its not like flashing the wrong ROM onto it.

2&3. what are looking to learn from your styles?
 
Upvote 0
1. Learn how to use the Logcat function. it will save you thousands of questions and allow you to pinpoint your problems. 99% of the time it will point you right to the problematic line in your code and let you know what is wrong with it.

Also, I hate the AVd, its slow, doesnt work exactly like a phone and lacks many real world capabilities without adding additional functioning in. basically a phone or tab is quicker and easier. And most apps aren't dangerous to your phone, they will just close. its not like flashing the wrong ROM onto it.

2&3. what are looking to learn from your styles?

I have chosen to discard that project. But I understand, logcat can probably be good to use. Had just a little hard to interpret it. I can post it in the forum next time if I don't understand it.

Thanks anyway ;)
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones