开发者

android layout issue - separating the screen into two layouts (inside a tab)

开发者 https://www.devze.com 2023-04-08 20:34 出处:网络
I have tabhost and in 1 tab I want to do the following: 1. At the top - a search edittext. 2. Below it some textbox. When user press the search bu开发者_如何学运维tton - I need this textbox to be chan

I have tabhost and in 1 tab I want to do the following: 1. At the top - a search edittext. 2. Below it some textbox. When user press the search bu开发者_如何学运维tton - I need this textbox to be changed into a list, on the rest of the screen (below the search).

Actually I need to separate the screen into 2 part.


There is more than one way, but something like this is fairly basic and should work. If you use a ListActivity just specify the image as the id/empty and the listview as the id/list. Then when your list is empty, users see the ImageView. When you populate it, it'll switch automatically.

<LinearLayout ...
  android:orientation="vertical">

  <LinearLayout ...>

    <EditText .../>

    <ImageButton .../>

  </LinearLayout>

  <ImageView ...
     android:id="@android:id/empty"/>

  <ListView ...
     android:id="@android:id/list"/>

</LinearLayout>

If you can't use ListActivity, just do it yourself (e.g. in the click listener for the button):

ImageView image = findViewById(R.id.YOUR-IMAGEVIEW);
image.setVisibility(View.GONE);

ListView list = findViewById(R.id.YOUR-LISTVIEW);
list.setVisibility(View.VISIBLE);

And be sure to set android:visibility="gone" on your list in the XML to make it be initially hidden.


Add a common layout in tab host as parent layout and add or remove the view as u like.

0

精彩评论

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

关注公众号