Reputation: 9
I was wondering if is possible to create two edittext identically on same Activity without create a new id. For example, use one id to control both edittext.
<EditText
android:id="@+id/editText_timeminute"
android:layout_width="58dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="10"
android:inputType="numberDecimal"
android:maxLength="3" />
I tried to add this in layout without sucess:
<EditText
android:id="@id/editText_timeminute"
android:layout_width="58dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:ems="10"
android:inputType="numberDecimal"
android:maxLength="3" />
Upvotes: 0
Views: 46
Reputation: 350
No, you can't, the id must be unique for every item inside the same xml layout. But you can use the same id for different items in different layouts (this answer explains it: https://stackoverflow.com/a/15811503/5837758).
Upvotes: 1
Reputation: 1583
You can't have 2 views with the same id on a layout (in different layouts it is possible). The ids are layout-wide unique.
Upvotes: 0