You can set ID's you'll use later in R.id class using an xml resource file, and let Android SDK give them unique values during compile time.
res/values/ids.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<item name="my_edit_text_1" type="id"/>
<item name="my_button_1" type="id"/>
<item name="my_time_picker_1" type="id"/>
</resources>
To use it in code:
myEditTextView.setId(R.id.my_edit_text_1);
沒有留言:
張貼留言