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