Back to project page androidui.
The source code is released under:
MIT License
If you think the Android project androidui listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package course.examples.UI.Button; //from www. java2 s . c om import android.app.Activity; import android.os.Bundle; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class ButtonActivity extends Activity { int count = 0; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); // Get a reference to the Press Me Button final Button button = (Button) findViewById(R.id.button); // Set an OnClickListener on this Button // Called each time the user clicks the Button button.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // Maintain a count of user presses // Display count as text on the Button button.setText("Got Pressed:" + ++count); } }); } }