0
가시성을 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