Issue
I had try somethimg like this I had seen example have its drawable name and find resource id ..Now I don't know drawable name I just have to find it from imgresourceId
This is my Image Resource Id
int id = Integer.parseInt(data.getStringExtra("imgId"));
05-30 12:09:33.648: D/imgid(5461): 2130837579
I want to set this to drawable right of a edittext
So I had done something like this
ed_operator.setCompoundDrawablesRelativeWithIntrinsicBounds( null, null, id, null );
3rd parameter is expecting drawable so how to convert this image resource id to drawable
is there any alternative solution which I can apply....
Solution
hey there you are putting resource ID (intenger) as extra. and getting with string extra. make it as
int resID = data.getIntExtra("imgId",-1);
if(resID != -1 ){
Drawable img = getResources().getDrawable( resID );
img.setBounds( 0, 0, 60, 60 );
ed_operator.setCompoundDrawablesRelativeWithIntrinsicBounds( null, null, img, null );//if you dont have images already in drawable
//OR
ed_operator.setCompoundDrawables( null, null,img,null);//if you had set images in your drawable
}
Answered By - shobhan
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.