PerformClick is the use of code to invoke the control's Click event (simulating manual touch control)-----------------------------------------boolean Android.view.View.performClick ()
Call this view's Onclicklistener, if it is defined.
-
Returns:
-
True There was a assigned onclicklistener that were called, false otherwise is returned.
---------------------------------------------@Overrideprotected void OnCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate);Setcontentview (r.layout.activity_my);btn1 = (Button) Findviewbyid (r.id.button1);TV1 = (TextView) Findviewbyid (r.id.textview1); Btn1.performclick (); Btn1.setonclicklistener (New Onclicklistener () {@OverridePublic void OnClick (View v) {Tv1.settext ("has been clicked");}});
}
The above way to write, TV1 text is the default text, only have to write Setonclicklistener declaration in PerformClick, directly execute program talent display "has been clicked"
Android PerformClick use