0
我有一些奇怪的要求。我有一些菜單按鈕。當我點擊按鈕時,應該看到其他3個按鈕。但是當焦點移動到另一個菜單按鈕時,這3個按鈕應該隱藏或變得不可見。我做了第一個要求。但無法做到第二。我採用相對佈局的三個按鈕。按鈕隱藏但未顯示焦點在Android中移動時
<RelativeLayout android:id="@+id/relativelayout_inventory"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/relativelayout_menu"
android:layout_toRightOf="@id/relativelayout_checkout"
android:layout_marginTop="10px"
android:layout_marginLeft="18px"
android:visibility="invisible"
>
<Button android:id="@+id/stckupdt"
android:background="@drawable/stckupdt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
</Button>
<Button android:id="@+id/pushoffer"
android:background="@drawable/stckstatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/stckupdt"
android:layout_marginTop="10px"
>
</Button>
</RelativeLayout>
並在Java文件,我寫像下面的代碼..
final Button button_inventory = (Button)findViewById(R.id.inventory);
final RelativeLayout view_inventory = (RelativeLayout)findViewById(R.id.relativelayout_inventory);
button_inventory.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
view_inventory.setVisibility(View.VISIBLE);
}
});
我在android平板電腦..因此它需要 – 2011-05-26 09:24:49
當按鈕不是焦點,其他3個按鈕被隱藏。當我點擊按鈕時,顯示3個按鈕。但是當我從按鈕移動時,3個按鈕不會隱藏。在xml中,最初我將相對佈局設置爲不可見。 – 2011-05-26 09:27:11
這與XML設計無關,只是您如何選擇菜單。您必須設置onTouch事件中菜單的可見性,它們的值指示操作(向下,向上或向下移動)。您必須手動設置可見性。 – 2011-05-26 09:33:41