मेरे पास एक 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
}
});