我的动态布局与下面的代码类似。inflater.inflate的动态资源ID
linearLayout=new LinearLayout(sActiveContext);
linearLayout.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.WRAP_CONTENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
CustomWebView webview=new CustomWebView(sActiveContext);
FrameLayout layout=webview.createwebview();
for (int i = 0; i < arrayList.size(); i++) {
if(tab.getPosition()==i)
{
webview.initwebview(arrayList.get(i));
mWebViewList.add(i, webview);
break;
}
}
linearLayout.addView(layout);
现在,我该如何膨胀这linearlayout?请提出一些建议。
你是什么意思?你已经在代码中实例化了LinearLayout,那么为什么要膨胀它呢? – Darwind 2013-04-18 06:02:16
@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){ 查看myFragmentView = inflater.inflate(R.layout.fragment_a,container,false); \t \t return myFragmentView; \t}在这个片段视图中,我如何添加初始化布局。这就是为什么我这样问。 – Karthick 2013-04-18 06:18:19
检查可能帮助你的类似帖子。 http://stackoverflow.com/questions/9851602/when-inflating-a-layout-xml-dynamically-multiple-times-how-can-i-differentiate – GrIsHu 2013-04-18 06:44:41