0
VisibilityをGone
に設定すると何らかの理由で表示要素の一部が非表示になることがありますが、Visible
に設定すると表示されません。一部の表示要素は表示されず、表示されないものもあります。
この例では、cmdCallMeは表示されず、cmdOkとcmdCancelも表示されません。他の要素はすべて期待どおりに動作します。
(ソースがわずかに短く)
アクティビティコード:
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.p2);
titleStatusView = FindViewById<TextView>(Resource.Id.lblP2Status);
outputTextView = FindViewById<TextView>(Resource.Id.lblP2Timer);
lblConfirm = FindViewById<TextView>(Resource.Id.lblP2Confirm);
cmdP2Update = FindViewById<Button>(Resource.Id.cmdP2Update);
cmdP2Arrived = FindViewById<Button>(Resource.Id.cmdP2Arrived);
cmdP2SelfDeployed = FindViewById<Button>(Resource.Id.cmdP2SelfDeployed);
cmdP2CallMe = FindViewById<Button>(Resource.Id.cmdP2CallMe);
cmdOk = FindViewById<Button>(Resource.Id.cmdP2CallMe);
cmdCancel = FindViewById<Button>(Resource.Id.cmdP2CallMe);
// hide normal buttons
// these all hide as expected
cmdP2Update.Visibility = ViewStates.Gone;
cmdP2Arrived.Visibility = ViewStates.Gone;
cmdP2SelfDeployed.Visibility = ViewStates.Gone;
// this should hide cmdCallMe but it doesn't change
cmdP2CallMe.Visibility = ViewStates.Gone;
// show confirm elements
// this appears as expected
lblConfirm.Visibility = ViewStates.Visible;
// the following 2 buttons should appear, but don't
cmdOk.Visibility = ViewStates.Visible;
cmdCancel.Visibility = ViewStates.Visible;
AXML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:text="Status: EN-ROUTE"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lblP2Status"
android:gravity="center" />
<TextView
android:text="00:00:00"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lblP2Timer"
android:gravity="center"
android:layout_marginBottom="19.0dp" />
<Button
android:text="Update"
android:layout_width="match_parent"
android:layout_height="64.5dp"
android:id="@+id/cmdP2Update"
android:layout_marginBottom="10.5dp"
android:background="@android:color/holo_green_dark" />
<Button
android:text="ARRIVED"
android:layout_width="match_parent"
android:layout_height="64.5dp"
android:id="@+id/cmdP2Arrived" />
<Button
android:text="SELF DEPLOYED"
android:layout_width="match_parent"
android:layout_height="64.5dp"
android:id="@+id/cmdP2SelfDeployed"
android:layout_marginBottom="10.5dp" />
<Button
android:text="CALL ME"
android:layout_width="match_parent"
android:layout_height="64.5dp"
android:id="@+id/cmdP2CallMe"
android:layout_marginTop="0.0dp" />
<TextView
android:text="Are you sure?"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/lblP2Confirm"
android:gravity="center"
android:layout_marginBottom="16.0dp"
android:visibility="gone" />
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/linearLayout1">
<Button
android:text="OK"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:id="@+id/cmdOk"
android:visibility="gone" />
<Button
android:text="Cancel"
android:layout_width="190dp"
android:layout_height="wrap_content"
android:id="@+id/cmdCancel"
android:visibility="gone" />
</LinearLayout>
</LinearLayout>
私が期待どおりに割り当てられているすべての値をステップします。要素の可視性が必ずしもこれを反映しているわけではありません。あなたのコードで
私はあなたに何を伝えることができますか?遅かった... ;) – CompanyDroneFromSector7G