Tôi có một RelativeLayoutnút chứa hai nút. Mà chồng chéo lên nhau.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#FFFFFF">
<Button android:text="Play"
android:id="@+id/play"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom = "true">
</Button>
<Button android:text="Stop "
android:id="@+id/stop"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom = "true">
</Button>
</RelativeLayout>
Tôi muốn lập trình chỉ hiển thị một nút tại một thời điểm khi sự kiện nhấp chuột của nó được gọi.
Tôi đã thử nó với:
playButton.setVisibility(1);
nhưng nó không hoạt động. Sau đây là một ví dụ những gì tôi đang cố gắng làm.
playButton = (Button) findViewById(R.id.play);
playButton.setVisibility(1);
playButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//when play is clicked show stop button and hide play button
}
});