what I’d like to do is draw an image into the AutoCompleteTextView widget.
after some research at:
http://www.droidnova.com/playing-with-graphics-in-android-part-i,147.html
and
http://developer.android.com/resources/samples/NotePad/src/com/example/android/notepad/NoteEditor.html
I’ve put the following class together …
public class myAutoCompleteTextView extends AutoCompleteTextView
{
//member variables
private Rect mRect;
private Paint mPaint;
/**
* Constructors used by LayoutInflater
*/
public myAutoCompleteTextView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
mRect = new Rect();
mPaint = new Paint();
}
public myAutoCompleteTextView(Context context, AttributeSet attrs)
{
super(context, attrs);
mRect = new Rect();
mPaint = new Paint();
}
public myAutoCompleteTextView(Context context)
{
super(context);
mRect = new Rect();
mPaint = new Paint();
}
@Override
protected void onDraw(Canvas canvas)
{
Bitmap _scratch = BitmapFactory.decodeResource(getResources(), R.drawable.search);
//canvas.drawBitmap(_scratch, 0.0f, 0.0f, mPaint);
canvas.drawBitmap(_scratch, 0.0f, 0.0f, null);
// Finishes up by calling the parent method
super.onDraw(canvas);
//this.invalidate();
}
}
and the XML layout…
<com.test.customcontrols.myAutoCompleteTextView
android:id="@+id/myautocomplete"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:layout_marginTop="20dip"
android:gravity="center_horizontal"
android:layout_gravity="center_horizontal"
android:inputType="textCapWords|textNoSuggestions|textVisiblePassword"/>
unfortunately, the AutoCompleteTextView appears seemingly untouched.
What shall I do to have my image incorporated onto the widgets’ usual background ?
making custom components will take a bit of detailed study… in the meantime I solved it with: