0

I've tabs as activities. In one of the tabs I have a search dialog. When I inflate the search result my tabs disappear. How can I inflate the result while preserving the tabs?

Here's how I inflate the result:

LinearLayout layout = (LinearLayout) findViewById(R.id.quick_search);

if(data==null) {

    LinearLayout empty = (LinearLayout) mInflater.inflate(R.layout.empty, null);

    layout.addView(empty);

}
else {

    LinearLayout workRequest = (LinearLayout) mInflater.inflate(R.layout.quick_search, null);

    layout.addView(workRequest);
}

Actually I want to display the searched result in place of LinearLayout 'quick_search' and make sure that the view above 'quick_search' is not lost. My current method inflates the result to occupy the whole screen. How can I avoid that?

Harsh
  • 487
  • 3
  • 9
  • 29

3 Answers3

1

See the below link

https://stackoverflow.com/a/2336047/1441666

RelativeLayout item = (RelativeLayout)findViewById(R.id.item);
View child = getLayoutInflater().inflate(R.layout.child);
item.addView(child);
Community
  • 1
  • 1
Nirali
  • 13,571
  • 6
  • 40
  • 53
  • I tried this. The only difference between your answer and my code is you've specified child as a view instead of a Layout right? It doesn't work. I mean the view is inflated but it occupies the whole screen and I lose my tabs at the bottom. – Harsh Jul 18 '12 at 13:50
0

If quick_search or empty have layout attributes of layout_width and/or layout_height set to match_parent, then they will occupy the whole screen when you inflate them. Either set them to wrap_content or some fixed value to avoid this.

Jason L
  • 1,812
  • 2
  • 22
  • 43
0

You need a ActivityGroup within the Tab where you want to change the Activity. If you just go on and create a new Activity and display it, your Tab Layout is no longer visible. See this: http://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity

user1417127
  • 1,525
  • 1
  • 21
  • 29
  • I'm not creating a new activity not even changing an activity. I'm just trying to inflate a new view. – Harsh Jul 18 '12 at 02:25