android setVisibility有时候工作有时不行

时间:2016-07-15 19:10:40

标签: java android

当我的应用程序转到后台并且在 setVisibility(View.VISIBLE)之后无法正常工作时,setVisibility出现问题我有一个套接字

private Emitter.Listener onNewRequest = new Emitter.Listener() {
    @Override
    public void call(final Object... args) {
        MainMapActivity.this.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                JSONObject objectRequet = (JSONObject) args[0];
                setComponentVisible();
            }
        });
    }
};

我的功能是

public void setComponentVisible() {
    runOnUiThread(new Runnable() {
        @Override
        public void run() {
            llAcceptReject.setVisibility(View.VISIBLE);
            llAcceptReject.requestLayout();
            llUserDetailView.setVisibility(View.VISIBLE);
            llUserDetailView.requestLayout();             

        }
    });
    playBeep();
    phelper.putJsonString(requestStr);
    phelper.putPending(true);
    startTimerRemain();


    destinationTxt.setText("Origen: " +originStr);
}

和我的布局xmol文件

 <fragment
    android:id="@+id/map"
    android:name="com.google.android.gms.maps.SupportMapFragment"
    android:layout_width="match_parent"
    android:layout_height="fill_parent"
    android:layout_alignWithParentIfMissing="false"

    android:layout_marginTop="40dp" />
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentBottom="true"
    android:orientation="vertical"
    android:weightSum="1"
    android:textAlignment="center">

    <include
        android:id="@+id/clientDetailView"
        layout="@layout/include_detail_view"
        android:visibility="gone"
        />

    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="40dp"
        android:layout_alignParentBottom="false"
        android:layout_alignParentLeft="false"
        android:baselineAligned="false"
        android:layout_centerInParent="true"
        android:gravity="center_vertical|center_horizontal"
        android:layout_alignParentTop="true"
        android:id="@+id/swhide"
        android:background="#c7030303">

        <Switch
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Disponibilidad"
            android:id="@+id/switchAbiable"
            android:layout_alignParentBottom="true"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:paddingRight="15dp"
            android:textColor="#f8f7f7"
            android:textOff="off"
            android:textOn="on"
            android:textSize="24dp" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:textAppearance="?android:attr/textAppearanceSmall"
            android:text="Small Text"
            android:id="@+id/versionTxt"
            android:layout_above="@+id/switchAbiable"
            android:layout_alignParentLeft="true"
            android:layout_alignParentStart="true"
            android:layout_marginLeft="15dp"
            android:visibility="visible"
            android:textColor="#fefcfc" />
        <Button
            android:id="@+id/btnClientReqRemainTime"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_alignParentBottom="true"
            android:layout_centerHorizontal="true"
            android:layout_marginBottom="30dp"
            android:background="@drawable/round_button"
            android:gravity="center"
            android:text="58"
            android:textColor="@color/color_blue"
            android:textSize="@dimen/dimen_waiting_time"
            android:visibility="gone" />
    </LinearLayout>

    <LinearLayout
        android:id="@+id/llAcceptReject"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal"
      android:visibility="gone">

        <Button
            android:id="@+id/btnClientAccept"
            android:layout_width="200dp"
            android:layout_height="73dp"
            android:layout_alignParentBottom="true"
            android:layout_gravity="bottom"
            android:background="@mipmap/botonaceptar"
            android:gravity="center"
            android:textColor="@color/white"
            android:layout_weight="0.5" />

        <ImageView
            android:id="@+id/ivDivider"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:background="@null"
            android:src="@drawable/divider"
            android:visibility="gone" />

        <Button
            android:id="@+id/btnClientReject"
            android:layout_width="200dp"
            android:layout_height="73dp"
            android:layout_alignParentBottom="true"
            android:layout_gravity="bottom"
            android:layout_weight="0.5"
            android:background="@mipmap/botoncancelarpeticion"
            android:gravity="center"
            android:textColor="@color/white" />
    </LinearLayout>
在不活动时间后重新加载视图时会出现问题 请帮忙!

0 个答案:

没有答案