Issue
I have a value in my dimens.xml defined as follows:
<dimen name="input_text_width">250dp</dimen>
I want to use it to dynamically size the width of a TextView, as follows:
tv.setWidth(activity.getResources().getInteger(R.dimen.input_text_width));
The resource exists (checked in R.java). I have run "clean" on my project more than once. Why do I keep getting this exception?
android.content.res.Resources$NotFoundException: Resource ID #0x7f050012 type #0x5 is not valid
Solution
You have to get the dimension pixels...
int size = activity.getResources().getDimensionPixelSize(R.dimen.input_text_width);
textView.setWidth(size);
Answered By - Gopal Gopi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.