top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

Android: dynamically findViewById

+2 votes

I have a data collection that is associated with a list of EditText. The data is dynamically retrieved. So, how would I access EditText dynamically and associate the value from the collection.

EditText editText = (EditText) findViewById(<How to pass id dynamically?>);
editText.setText("<my value here>");
posted Jun 20, 2016 by Akshay

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote
Best answer

Yes, it is possible to findViewById dynamically,

EditText editText = (EditText) findViewById(getResources().getIdentifier(<YOUR_DYNAMIC_ID>, "id", getPackageName()));

The key is to use the getResources().getIdentifier method.

Hope this helps

answer Jun 24, 2016 by Vinod Kumar K V
Similar Questions
+3 votes

Hi, I have used the below sample code downloaded from a website and it is crashing.

Intent sendIntent = new Intent();
sendIntent.putExtra(Intent.EXTRA_TEXT, textMessage);
sendIntent.setType(HTTP.PLAIN_TEXT_TYPE); // "text/plain" MIME type

Let me know the possible solution.

+3 votes

With the major milestone release of Android Studio, I am worried about the suggested IDE for platform development. As we can see on the web [ ], there is a sort of tutorial to set up an Eclipse Environment for AOSP development: while it does not directly involve the ADT plugin, at the same time its presence in the environment it's useful in some situations.

Is there any plan for a substitution of Eclipse as "endorsed" IDE for AOSP?

+4 votes

What is Unable to resolve target 'android-15' until the SDK is loaded? IN eclipse I am getting the error while am try to run my app. Please help me how to solve this issue.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.