android - I need refresh imageView with a button(invalidate doesn't work) -



android - I need refresh imageView with a button(invalidate doesn't work) -

i have custom imageview can draw, zoom , paint points(coordinates).

i have button "reset" delete coordinates draw

but imageview doesn't refresh when click, refresh after, when touch screen.

gonna see code

here onclick of buttons- btnres

is button need help!

//this method on "main extends activity" public void onclick(view v) { switch(v.getid()){ case r.id.btnfin: break; case r.id.btninv: break; case r.id.btnres://start on imagen.listaptos.clear(); //refreshing image imagen.invalidate();//dont works imagen.refreshdrawablestate();//dont works neither break; } }

some thing class imagen understand after code

public class imagen extends imageview static arraylist <marking> listaptos = new arraylist<marking>();

some code imagen

@override public void ondraw(canvas c){ log.d("ondraw","pinta="+pinta); c.drawbitmap(bitmap, matrix, paintfondo); if(listaptos!=null){ for(marking mark:listaptos){ c.drawbitmap(cruz, mark.x, mark.y, paintpuntos); } } } //for coordinates class marking{ int x; int y; marking(int x, int y){ this.x = x; this.y = y; } marking(){} int getx(){ homecoming x; } int gety(){ homecoming y; } void setx(int x){ this.x = x; } void sety(int y){ this.y = y; }

}

any ideas?

i solve code insithe ondraw:

((main) context).runonuithread(new runnable() { @override public void run() { imagen.this.invalidate(); } });

not best solution 1 works

thx: http://stackoverflow.com/a/21732444/4116091

android button imageview refresh invalidate

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -