SORU
30 Mayıs 2011, PAZARTESİ


nasıl android sdk Program aracılığıyla bir düğme gizle

İki düğme içeren göreli bir düzen var. Birbirine bindirilir.

<?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>

Click olayı çağrıldığında bir zamanda program aracılığıyla tek bir düğme göstermek istiyorum. Onu da denedim :

playButton.setVisibility(1);

ama işe yaradı değil.Aşağıda yapmaya çalıştığım bir örnek.

    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

        }
    });

CEVAP
30 Mayıs 2011, PAZARTESİ


Aşağıdaki kodu kullanabilirsiniz

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
             playButton.setVisibility(View.GONE);
             stopButton.setVisibility(View.VISIBLE);

        }
    });

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • Austin Evans

    Austin Evans

    5 AĞUSTOS 2007
  • hans peder sahl

    hans peder s

    22 Temmuz 2009
  • Matthew Pearce

    Matthew Pear

    9 AĞUSTOS 2009