【发布时间】:2011-09-04 15:05:48
【问题描述】:
我有一个RelativeLayout,其中包含两个按钮。它们相互重叠。
<?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>
我想在调用其点击事件时以编程方式一次只显示一个按钮。
我试过了:
playButton.setVisibility(1);
但它不起作用。以下是我正在尝试做的一个例子。
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
}
});
【问题讨论】:
标签: android