[mono-android] WebView goes full screen when in tab layout
www at gencode.com
www at gencode.com
Wed Mar 16 19:58:22 EDT 2011
Craig,
That worked, I did have to change BaseActivity to Activity
Was that okay to do?
Also I don't really understand why I needed to do this with a webview but
not a textview as in the tab example
Ed,
___________________________________________________________
Ed Scott | Microsoft Certified Solutions Developer (MCSD)
www: http://www.gencode.com <http://www.gencode.com/>
emaill: escott at gencode.com
Location: Earth, Milkyway Galaxy
From: monodroid-bounces at lists.ximian.com
[mailto:monodroid-bounces at lists.ximian.com] On Behalf Of Craig Dunn
Sent: Wednesday, March 16, 2011 12:07 AM
To: monodroid at lists.ximian.com
Subject: Re: [mono-android] WebView goes full screen when in tab layout
Check out
http://developer.android.com/resources/tutorials/views/hello-webview.html --
you need to add a custom WebViewClient subclass (see below).
HTH
Craig
----------------------------------------------------------------------------
--------
using System;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Views;
using Android.Webkit;
namespace MagshopDemo.Activities
{
[Activity(Label = "Web View Example")]
public class WebActivity : BaseActivity
{
private WebView _browser;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Web);
var virtualPath = Intent.GetStringExtra("VirtualPath");
_browser = FindViewById<WebView>(Resource.Id.browser);
_browser.Settings.JavaScriptEnabled = true;
_browser.SetWebViewClient(new CustomWebViewClient());
_browser.LoadUrl(@"http://www.server.com/" + virtualPath);
}
public override void OnBackPressed()
{
if (_browser.CanGoBack())
{
_browser.GoBack();
}
else
{
base.OnBackPressed();
}
}
}
public class CustomWebViewClient : WebViewClient
{
public CustomWebViewClient()
: base()
{ }
public override void OnPageStarted(WebView view, string url,
Android.Graphics.Bitmap favicon)
{
base.OnPageStarted(view, url, favicon);
}
public override bool ShouldOverrideUrlLoading(WebView view, string
url)
{ //
http://developer.android.com/resources/tutorials/views/hello-webview.html
view.LoadUrl(url);
return true;
}
}
}
----------------------------------------------------------------------------
--------
On Wed, Mar 16, 2011 at 2:43 PM, <www at gencode.com> wrote:
I made an app using the tab layout example
The example uses TextViews
I simply changed the textview to webview
As shown below, but I did not get an embedded webview inside the tabs as
expected like the textview does, instead I got a full screen browser
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
WebView web_view = new WebView(this);
web_view.Settings.JavaScriptEnabled = true;
web_view.LoadUrl("http://www.google.com");
SetContentView(web_view);
}
___________________________________________________________
Ed Scott | Microsoft Certified Solutions Developer (MCSD)
www: http://www.gencode.com <http://www.gencode.com/>
emaill: escott at gencode.com
Location: Earth, Milkyway Galaxy
_______________________________________________
Monodroid mailing list
Monodroid at lists.ximian.com
UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110316/0a121bfd/attachment.html
More information about the Monodroid
mailing list