所以我的布局仍然可见,也许有人看到错误?我想在点击infoButton(imagebutton)时取消它。
<pre>
<%= select_tag "sippeer_type", options_from_collection_for_select(@guest_server, "id", "name") %>
</pre>
我说:How to change visibility of layout programaticly
EDITED: 错误的代码部分,仍然不适合我
答案 0 :(得分:0)
*试试这个**
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.demo.MainActivity" >
<FrameLayout
android:id="@+id/serviceLayout"
android:layout_width="match_parent"
android:layout_height="150dp"
android:background="#000000" />
<Button
android:id="@+id/btnHide"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:onClick="infoPressed"
android:text="Hide" />
</RelativeLayout>
<强> MainActivity.java 强>
public class MainActivity extends Activity
{
FrameLayout infolayout;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
infolayout = (FrameLayout) findViewById(R.id.serviceLayout);
}
public void infoPressed(View v){ //info button is pressed by user
//infoLayout.setVisibility(View.GONE);
infolayout.setVisibility(View.INVISIBLE);
}
}
答案 1 :(得分:-2)
如果您的身份证明声明正确,我猜您必须更改行
infolayout.setVisibility(View.INVISIBLE);
到
infolayout.setVisibility(FrameLayout.INVISIBLE);