Issue
Let's assume I have this in layout of res in my app
<TextView android:id="@+id/titleText" android:layout_width="fill_parent"
android:layout_height="wrap_content" android:text="@string/app_name"
android:textColor="#ffffffb0" android:padding="5px" />
In my activity, I get the TextView using this command
TextView tv = (TextView)findViewById(R.id.titleText);
But I am looking for another method like this
TextView tv = (TextView)findViewByString("R.id."+"titleText");
Because I need to enumerate those ids. Can any of you give a hint or clue how I can go about it?
Solution
You can use something like this:
Resources res = getResources();
int id = res.getIdentifier("titleText", "id", getContext().getPackageName());
And then use the id.
Answered By - Ted Hopp
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.