Thanks for your reply.
> 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.
I am able to inflate WebView using a view inflator and adding my View
on top of it.
I wonder why is it so? first and foremost I had to add the following
code.
static final FrameLayout.LayoutParams FULL_SCREEN_PARAMS =
new FrameLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT);
FrameLayout frameLayout = (FrameLayout)
getWindow().getDecorView(); // not clear with
why this works!!
mInflator = (FrameLayout)
LayoutInflater.from( this ).inflate(R.layout.launch, null);
mContentView = (FrameLayout)
mInflator.findViewById( R.id.webview_wrapper);
as per your suggestion I am adding layout params to view here -
frameLayout.addView( mInflator ,FULL_SCREEN_PARAMS );
that is a frameLayout view holder for my activity. And the rest of the
code is same.
My problem now is I am unable to save WebView state.
I want to display the same WebView each time a specific page loads
that has been sent to background.
I tried calling mWebView.onResume() specific to WebView object that I
have.
But it doesn't seem to work. Can you suggest me how to achieve this.
Thanks
-- Prateek
On Jun 10, 6:38 pm, Kostya Vasilyev <[email protected]> wrote:
> 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