This program is for make a button enable and disable.
Step 2) Put below code in your main java file
package cal.ender;
import java.util.Calendar;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class CalenderActivity extends Activity {
/** Called when
the activity is first created. */
@Override
public void
onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
final Button
btn1=(Button)findViewById(R.id.button1);
Button
btn2=(Button)findViewById(R.id.button2);
Button
btn3=(Button)findViewById(R.id.button3);
btn2.setOnClickListener(new OnClickListener() {
public
void onClick(View arg0) {
//
TODO Auto-generated method stub
btn1.setEnabled(false);
}
});
btn3.setOnClickListener(new OnClickListener() {
public
void onClick(View arg0) {
//
TODO Auto-generated method stub
btn1.setEnabled(true);
}
});
}
}
Step 2) Code for main.xml file
<?xml version="1.0"
encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:weightSum="1">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button android:text="Change
me" android:id="@+id/button1"
android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Disable"
android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
<Button android:text="Enable"
android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
</LinearLayout>