开发者

How do I hide ListView on click?

开发者 https://www.devze.com 2023-01-29 03:19 出处:网络
In my XML file I have: <ListViewandroid:id=\"android:id/list\" android:layout_height=\"fill_parent\"

In my XML file I have:

<ListView  android:id="android:id/list" android:layout_height="fill_parent"
  android:layout_width="fill_parent" android:visibility="visible" 

  android:scrollbarAlwaysDrawVerticalTrack="true" android:fadingEdge="none">


</ListView>

My Java code:

public OnClickListener teamlisten = new OnClickListener() {
     public void onClick(View v) {
       // do something when the button is clicked

     View list = (View)findViewById(R.id.myviewId);
      list.setVisibility(View.INVISIBLE);

     }
 };

As you can see I'm trying to set my listview to invisible, the problem is I ca开发者_StackOverflown't get it to appear in my R.java so I can't seem to make it invisible. I only want the listview to turn invisible when a button is pressed.

Any help on this one would be appreciated.


Use getListView().setVisibility(View.INVISIBLE); within your ListActivity.

This is how it looks inside your code:

public OnClickListener teamlisten = new OnClickListener() {
   public void onClick(View v) {
      getListView().setVisibility(View.INVISIBLE);
   }
};
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号