android - How to add cursor and activate my editText? -


actually creating custom edittext in android application. have done have created class called customedittext, in drawing edittext. code follows:

public class customedittext extends view {  string mtext; context mcontext; paint paint = new paint();  public customedittext(context context) {     super(context);     mcontext = context;     paint.setcolor(color.white); // setup background etc here     paint.setstyle(style.fill); }  @override protected void ondraw(canvas canvas) {     super.ondraw(canvas);     drawtextoncanvas(canvas, mtext); }  private void drawtextoncanvas(final canvas canvas, string mtext) {     canvas.drawpaint(paint);      final edittext edittext = new edittext(mcontext);     edittext.settextcolor(black);     edittext.setenabled(true);      edittext.setdrawingcacheenabled(true);     edittext.measure(measurespec.makemeasurespec(canvas.getwidth(), measurespec.exactly), 50);      edittext.layout(0, 0, edittext.getmeasuredwidth(), edittext.getmeasuredheight());      canvas.drawbitmap(edittext.getdrawingcache(), 0, 0, paint);     edittext.setdrawingcacheenabled(false); } 

and class being called in mainactivity using following code:

    customedittext edittext = new customedittext(this);     setcontentview(edittext); 

what should doing next add cursor , make customedittext act normal edittext( means should able accept, select , clear input text ).

if drawtextoncanvas() working properly, making customedittext extend edittext should work. (instead of view)

if understand comment correctly, have :

public class customedittext extends edittext {     context mcontext;    paint paint;    edittext edittext;      @targetapi(build.version_codes.jelly_bean_mr1)    public customedittext(context context) {       super(context);       paint = new paint();       edittext = new edittext(context);       mcontext = context;       paint.setcolor(color.green);        paint.setstyle(paint.style.fill);    }    @override   protected void ondraw(canvas canvas) {      canvas.drawpaint(paint);      super.ondraw(canvas);   } }  

Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -

How to provide Authorization & Authentication using Asp.net, C#? -