2013-08-01 109 views
0

我有以下的方法,我想了幾個按鈕來顯示圖像和按鈕的點擊休息時,應該是看不見的。無論其他v.getId()是我希望它是不可見的。檢測按鈕被點擊,並使其不可見

public void onClick(View v) 
     { 
      if(v.getId() == R.id.d){ 
       imgD.setVisibility(View.VISIBLE); 
      }else if(v.getId() == R.id.i){ 
       imgI.setVisibility(View.VISIBLE); 
      }else if(v.getId() == R.id.l){ 
       imgL.setVisibility(View.VISIBLE); 
      }else{ 
       //if other buttons are clicked then the button must be invisible. 
      } 
     } 
+0

沒有ü累了的財產? – KOTIOS

+0

請正確解釋我不能站立? –

+0

或此鏈接聊天我西港島線幫助ü正確http://chat.stackoverflow.com/rooms/522/android-for-life –

回答

1

對於隱身時間,有android的方法,

imgD.setVisibility(View.GONE); 

讓我知道是它的工作或沒有?

0

使用View.GONE

yourview.setVisibility(View.GONE); 

public static final int GONE

在API級別1

這種觀點是不可見的,並且它不採取任何空間佈局的目的。使用setVisibility(int)和android:visibility。

如果使用INVISIBLE的觀點是無形的,但佔用的佈局空間。

+0

請重新閱讀我的問題。 – ivesingh

+0

@ivesingh你有什麼建議,上述將無法正常工作? – Raghunandan

+0

@ivesingh如果點擊其他按鈕,該按鈕必須是不可見的。你能否詳細說明這一點 – Raghunandan

0

嘗試

else{ 
    yourButton.setVisibility(View.INVISIBLE);// it will take the space in layout 
    //or 
    yourButton.setVisibility(View.GONNE);// it will not take the space in layout 

    }