如果最初设置为invisble,则不会显示android setVisibility

如果最初设置为invisble,则不会显示android setVisibility,第1张

概述我有一个glsurface占据全屏幕.点击一个按钮,我想要出现另一个布局(设置类型的东西).如果我从叠加层开始可见,我可以使它不可见,然后再次可见,没有任何问题.但是,如果我从它开始看不见,我不能让它再次可见.代码如下:<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutxmlns:

我有一个glsurface占据全屏幕.点击一个按钮,我想要出现另一个布局(设置类型的东西).如果我从叠加层开始可见,我可以使它不可见,然后再次可见,没有任何问题.但是,如果我从它开始看不见,我不能让它再次可见.代码如下:

<?xml version="1.0" enCoding="utf-8"?><relativeLayout xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="match_parent"androID:layout_height="match_parent" >    <androID.opengl.GLSurfaceVIEw    androID:ID="@+ID/glPlaySurface"    androID:layout_wIDth="match_parent"    androID:layout_height="match_parent" ></androID.opengl.GLSurfaceVIEw><RadioGroup    androID:ID="@+ID/radioGroup1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:layout_alignParentleft="true"    androID:orIEntation="horizontal" >    <Radiobutton        androID:ID="@+ID/btnRotate"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_marginleft="10dp"        androID:checked="true"        androID:text="R"        androID:textcolor="#000" />    <Radiobutton        androID:ID="@+ID/btnPan"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:layout_marginleft="15dp"        androID:text="P"        androID:textcolor="#000" /></RadioGroup><button    androID:ID="@+ID/btnlights"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:layout_marginleft="15dp"    androID:layout_toRightOf="@+ID/radioGroup1"    androID:text="lights" /><relativeLayout    xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:ID="@+ID/layoutlights"    androID:layout_wIDth="100dp"    androID:layout_height="100dp"    androID:visibility="visible" <--- Does not work if set to invisible    androID:layout_alignParentBottom="true"    androID:layout_alignParentRight="true"    androID:background="#fff" >    <button    androID:ID="@+ID/btnlightsOK"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:layout_alignParentleft="true"    androID:layout_marginleft="15dp"    androID:text="OK" />    <button    androID:ID="@+ID/btnlights"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_alignParentBottom="true"    androID:layout_alignParentleft="true"    androID:layout_marginleft="15dp"    androID:text="OK" /></relativeLayout></relativeLayout>private OnClickListener mOnlightsClick = new OnClickListener() {    public voID onClick(VIEw arg0) {        if(mLayoutlights.getVisibility() == VIEw.VISIBLE) {            mLayoutlights.setVisibility(VIEw.INVISIBLE);        }        else {            mLayoutlights.setVisibility(VIEw.VISIBLE);        }    }};

解决方法:

有类似的错误,但这是由于我没有使用UiThread的愚蠢错误.

Activity act = (Activity)context;act.runOnUiThread(new Runnable(){@OverrIDepublic voID run() {    mLayoutlights.setVisibility(VIEw.VISIBLE);  } });
总结

以上是内存溢出为你收集整理的如果最初设置为invisble,则不会显示android setVisibility全部内容,希望文章能够帮你解决如果最初设置为invisble,则不会显示android setVisibility所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1098426.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存