Membuat Button atau Tombol di android.
File > New > Other > Android Aplication Project.
isi Activity Name : MainActivity
isi Layout Name : main
res/layout/main.xml
ContohButton1/src/com/contohbutton1/MainActivity.java
File > New > Other > Android Aplication Project.
isi Activity Name : MainActivity
isi Layout Name : main
res/layout/main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation="vertical" > <Button android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Button" android:src="#4584f7" /> <TextView android:id="@+id/tampil1" android:layout_width="fill_parent" android:layout_height="wrap_content"/> </LinearLayout>
ContohButton1/src/com/contohbutton1/MainActivity.java
package com.contohbutton1; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; import android.widget.TextView; public class MainActivity extends Activity implements OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button button1=(Button)findViewById(R.id.button1); button1.setOnClickListener(this); } @Override public void onClick(View arg0) { // ini adalah Method button TextView tampil1=(TextView)findViewById(R.id.tampil1); tampil1.setText("Anda Berhasil Mengklik Tombol Button ... "); } }Dan Hasilnya setelah di compile.