Reputation: 487
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?
Upvotes: 0
Views: 749
Reputation: 13825
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);
Upvotes: 1
Reputation: 1645
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
Upvotes: 0
Reputation: 1832
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.
Upvotes: 0