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?

4

3 回答 3

1

请参阅以下链接

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

RelativeLayout item = (RelativeLayout)findViewById(R.id.item);
View child = getLayoutInflater().inflate(R.layout.child);
item.addView(child);
于 2012-07-18T04:43:38.693 回答
0

如果quick_searchempty具有layout_width和/或layout_height设置为的布局属性match_parent,那么当您对它们进行充气时,它们将占据整个屏幕。将它们设置为wrap_content或某个固定值以避免这种情况。

于 2012-07-18T01:33:06.347 回答
0

您需要在要更改 Activity 的选项卡中的 ActivityGroup。如果您继续创建一个新的 Activity 并显示它,您的选项卡布局将不再可见。看到这个:http ://united-coders.com/nico-heid/use-android-activitygroup-within-tabhost-to-show-different-activity

于 2012-07-18T01:58:59.523 回答