Your code seems to go in two directions at once: by inflating a layout, and
creating a WebView with "new".

For instantiation with "new", I think you might need to set layout paramters
when calling addView - I would try FILL_PARENT / FILL_PARENT first.

For inflating a web view on demand, I'm using a ViewStub in my current
project, and it works without any issues. A ViewStub lets you only
instantiate a view if needed, and yet still specify layout paramters in the
XML.

Also note that you can reuse one WebView object for as many page load
operations as needed.

-- Kostya

2011/6/10 redVirus <[email protected]>

> Hello,
>
> My requirement is to create an activity that holds WebView.
> I want my activity to load WebView by creating WebView objects as per
> the requirements i.e. for every new web pageI want to reuse my
> activity.
>
> For this I have a layout for my activity. And I create new WebView for
> each request.
>
> Now my problem is I am unable to view the contents of the object I am
> creating.
>
> here is my code snippet please tell me what am I missing here.
>
>        public void onCreate(Bundle savedInstanceState) {
>                super.onCreate( savedInstanceState );
>
> /* Layout of My Activity */
>                mInflator = (FrameLayout)
> LayoutInflater.from( this ).inflate(R.layout.main, null);
>                mContentView = (FrameLayout)
> mInflator.findViewById( R.id.webview_wrapper);
>
> /* View having WebView */
>
>                webViewInflator = (FrameLayout)
> LayoutInflater.from( this ).inflate(R.layout.subLayout, null);
>                myView = (WebView)
> webViewInflator .findViewById( R.id.webview );
>
>                WebView obj = new WebView
> (this);                                                           //
> this is my requirement
>                obj .setWebViewClient( new
> myWebViewClient( getApplicationContext() ) );
>                obj .setWebChromeClient( new myWebChromeClient() );
>                obj .getSettings().setJavaScriptEnabled(true);
>                obj .loadUrl( url );
>
>                myView = obj;
>                mInflator.addView( webViewInflator );
>        }
>
> As per my requirement myView should load url that I am passing. Where
> am I wrong?
>
> Thanks for suggestions
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to