Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What false means in the android ids.xml file

Tags:

android

I notice that in the res/value folder of some android app's, there exists an ids.xml file with some item have false value what false means? can anyone tell me ,thank!

like image 896
lambokini Avatar asked Feb 25 '12 09:02

lambokini


People also ask

What is IDs XML in Android?

id. xml is generally used to declare the id's that you use for the views in the layouts. for your given xml. Any advantage in defining it in "ids.

What is id in XML?

Under XML 1.0, an ID is a unique identifier to aid in processing. You can annotate an element uniquely with an attribute of type ID, as in id="i-35867" (IDs can't start with a number), which often assumes an associated DTD containing the attribute-list declaration <!

Why do we use @+ id in Android?

TL;DR: The plus sign in “@+id/” tells Android build tools that you are declaring a new resource. And if it does not exist, add to R. java file. But basically, you don't have to think, just use “@+id/” anywhere you want!

What does Android ID do?

android:id. Resource ID. A unique resource name for the element, which you can use to obtain a reference to the View from your application.


1 Answers

I believe you see these when you decompile an apk file. After some trial and error, I found out that the false does not actually do anything. You can put anything instead of a boolean.

So why is false is appearing? According to my experiments if you create a file ids.xml in your project after I compile my apk I would see exactly the same line in the compiled ids.xml as I see in my projects ids.xml. However, if I do not place my id in the ids.xml and create it using @+id/myId I will see a tag in the compiled ids.xml with a false as its value. I hope it answers your qestion

My ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item name="test_id" type="id"/>
    <item name="test_id2" type="id">false</item>
    <item name="test_id3" type="id">This is a test String</item>
    <item name="test_id4" type="id">749274927492</item>
</resources>

In My Layout

<TextView
        android:id="@+id/myId"
        android:text="@string/hello_world"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" />

Generated ids.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <item type="id" name="test_id" />
    <item type="id" name="test_id2">false</item>
    <item type="id" name="test_id3">This is a test String</item>
    <item type="id" name="test_id4">1950617988</item>
    <item type="id" name="myId">false</item>
    <item type="id" name="action_bar_activity_content" />
    <item type="id" name="action_menu_divider" />
    <item type="id" name="action_menu_presenter" />
    <item type="id" name="action_bar_root">false</item>
    <item type="id" name="action_bar_container">false</item>
    <item type="id" name="action_bar">false</item>
    <item type="id" name="action_context_bar">false</item>
    <item type="id" name="split_action_bar">false</item>
    ....
</resources>
like image 149
hoomi Avatar answered Oct 12 '22 00:10

hoomi