Defining IDs
If a view needs to be accessed via Java code (see Section 19.2, “Accessing views from the layout in the activity ”), you have to give theView
a unique ID
via the
android:id
attribute. To assign a new
ID to a
View
use
. The following shows an example in which a
@+id/yourvalue
Button
gets the
button1
ID assigned.
<Button android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="Show Preferences" > </Button>
By conversion this will create and assign a new
yourvalue
ID
to the corresponding
view.
No comments:
Post a Comment