package app.test;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Test extends Activity {
OnClickListener listener1 = null;
OnClickListener listener2 = null;
Button button1;
Button button2;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
listener1 = new OnClickListener() {
public void onClick(View v) {
setTitle("button1");
button1.setVisibility(View.INVISIBLE);
button2.setVisibility(View.VISIBLE);
}
};
listener2 = new OnClickListener() {
public void onClick(View v) {
setTitle("button2");
button2.setVisibility(View.INVISIBLE);
button1.setVisibility(View.VISIBLE);
}
};
setContentView(R.layout.main);
button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(listener1);
button2 = (Button) findViewById(R.id.button2);
button2.setOnClickListener(listener2);
}
}
//main.xml
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
android:layout_marginTop="2dip" android:layout_width="wrap_content"
android:ems="25" android:layout_height="wrap_content"
android:autoText="true" android:scrollHorizontally="true" />
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text="button1" />
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:text=" button2" />