0

I am having the dynamic layout as like the below code.

        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);

Now, how can I inflate this linearlayout? Please give some suggestions.

Karthick
  • 1,241
  • 5
  • 20
  • 43
  • What do you mean? You've already instantiated the `LinearLayout` in code, so why inflate it? – Darwind Apr 18 '13 at 06:02
  • @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) { View myFragmentView = inflater.inflate(R.layout.fragment_a, container, false); return myFragmentView; } In this fragment view, how can I add the initialized layout.That's why I'm asking like this. – Karthick Apr 18 '13 at 06:18
  • Check the similar post which might help you. http://stackoverflow.com/questions/9851602/when-inflating-a-layout-xml-dynamically-multiple-times-how-can-i-differentiate – GrIsHu Apr 18 '13 at 06:44

1 Answers1

0

you just return linearlayout object at return statement of onCreateView. or else you can add that linear layout object to your already inflated view(myFragmentView) you can inflate only xml layout files and not dynamic layout.

dev1993
  • 231
  • 3
  • 17
  • If I am returning the linearlayout, the fragment is not initiated at all. myFragment = Fragment.instantiate(myActivity, myClass.getName());ft.add(android.R.id.content, myFragment, myTag); How can I initiate this fragment using the dynamically created linearlyout. – Karthick Apr 18 '13 at 06:37
  • can you elaborate your requirement? ft.add(android.R.id.content, myFragment, myTag) Did you commit this transaction? – dev1993 Apr 18 '13 at 07:54
  • I have created all those things like in this post. http://stackoverflow.com/questions/16077002/fragment-webview-java-script-function-is-not-working/ Now, I am facing the javascript to native method call is not working, while showing the fragment. Can you please give me the suggestion why this happened to me? – Karthick Apr 18 '13 at 08:45