The text1 part (and the other buttons) are the reference for your java code to the textView defined in your layout. xml. the rest of that Android.R.id tells the code to find an Android resource with an Id of 'text1' for example.
The Android unique device ID is called the Android Advertising ID (AAID). It's an anonymized string of numbers and letters generated for the device upon initial setup.
R class is generated by Android tools from your resources before compiling your code. It contains assigned numeric constant for each resource that you can refer in your project. For example, you have XML resource file that contains about_button .
R is a Class that contains the ID's of all the Views. findViewById is the method that finds the View by the ID it is given. So findViewById(R. id. myName) finds the View with name 'myName'.
As Philipp Reichart commented:
android.R.id.content
gives you the root element of a view, without having to know its actual name/type/ID. Check out http://stackoverflow.com/questions/4486034/android-how-to-get-root-view-from-current-activity
The android.R.id.content
ID value indicates the ViewGroup
of the entire content area of an Activity
.
It can be used with Fragment
:
public class MyActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction()
.add(android.R.id.content, MyFragment.newInstance())
.commit();
}
}
...
}
The code above will insert the View
created by Fragment
into the ViewGroup
identified by android.R.id.content
.
Google designers develop Android UX with specific or recommended design guidelines. The layout android.R.id.content defines a linearlayout with a few attributes Android believes are a good standard.
Thus loading a Fragment Manager's root view with android.R.id.content ensures these guidelines are implemented.
NOTE: This layout has set the attribute: android:addStatesFromChildren="true" to allow child fragments to overwrite attributes in this rootview.
As of version 19, android.R.id.content is defined in a file: auto_complete_list.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/content"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/edit_text"
android:divider="@android:drawable/divider_horizontal_textfield"
android:addStatesFromChildren="true">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With