FindViewById where ID is dynamic string
You can get an identifier from a string by using:
notes = (TextView)findViewById(getResources().getIdentifier(VIEW_NAME, "id", getPackageName()));
Where VIEW_NAME
is whatever identifier string you're generating. After that, you can set the text of it like you currently are. This also works if you need to get strings and drawables as well, just change id
to the appropriate type.
Assuming you're passing in the actual string "R.id.passed_id", I would recommend passing in the integer value instead. Thus, simply pass in R.id.passed_id.
All values in the R file of an application are simply integers that are mapped to resource locations. The findById()
methods are only looking for integers, so if you start the Activity
and pass in the integer value of the resource you want, it will find it.
Note: This will only work if the resources are within the same application. R files remain constant for an application, but they can change from one app to another even if they have the same name. If, however, the two activities fall under the same application package, it will work.
Man I'm not understating what exactly you want to do.Id is the id off an android widget then on function initialize() you should cast string to int this way: Integer.ValueOf(Id)Hope this is what you want.