Search code examples
androideventstextviewredraw

How to issue redraw event when textview invoke setText method for android?


We usually code like this innner OnClickListener:

new OnClickListener (){
   void onClick(View v){
              if(v.getId()==R.id.textView1){
                 (TextView) findViewById(R.id.textView1).setText("123456789.......");
                }
    }
 }

If the textView1 view layout_width and layout_height is wrap_content. After the handle click event, the textView1 view and its parent view may be need to be remeasured and redrawn. How to know some view need remeasure and redraw? Is there someone give more detail information for the event chain dispatch?

thanks.


Solution

  • TextView's setText method calls invalidate, which causes the remeasure and redraw.