試圖讓採用的是Android檢查單選按鈕的ID,這是我的XML代碼,獲取點擊的單選按鈕的ID在Android的
<RadioButton
android:id="@+id/RadioAuction"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="55dp"
android:onClick="showAuctionOptions"
android:textColor="#3DCC00"
android:text="@string/RadioButton1" />
<RadioButton
android:id="@+id/RadioBin"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:textColor="#FF0000"
android:text="Buy it now" />
所以一旦被點擊運行showAuctionOptions,這是我的java代碼,
public void showAuctionOptions(View v){
if(findViewById(R.id.v=="RadioAuction")){
//Display start price
LinearLayout ShowPrice = (LinearLayout)findViewById(R.id.LayoutStartPrice);
ShowPrice.setVisibility(View.VISIBLE);
//Display reserve price
LinearLayout ShowReservePrice = (LinearLayout)findViewById(R.id.LayoutReservePrice);
ShowReservePrice.setVisibility(View.VISIBLE);
}
}
但是,這不起作用,有誰知道爲什麼?謝謝。
難道它甚至編譯? – 2012-04-01 21:06:26