[android-developers] webview in tabs

2011-03-22 Thread seyma
Hi! I've just started to create monodroid applications. So I'm in
trouble about my project. I want to create 2 tabs and when clicks each
open a web site. Is it possible ? Here is my code. Tabs already work
but when I click nothing happens.


[Activity(MainLauncher = true, Label = "@string/app_name", Theme =
"@android:style/Theme.NoTitleBar")]
public class HelloTabWidget : TabActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);

TabHost.TabSpec spec; // Resusable TabSpec for each
tab
Intent intent;// Reusable Intent for each
tab

// Create an Intent to launch an Activity for the tab (to
be reused)
intent = new Intent(this, typeof(ArtistsActivity));
intent.AddFlags(ActivityFlags.NewTask);

// Initialize a TabSpec for each tab and add it to the
TabHost
spec = TabHost.NewTabSpec("artists");
spec.SetIndicator("Artists",
Resources.GetDrawable(Resource.Drawable.ic_tab_artists));
spec.SetContent(intent);
TabHost.AddTab(spec);

// Do the same for the other tabs
intent = new Intent(this, typeof(AlbumsActivity));
intent.AddFlags(ActivityFlags.NewTask);

spec = TabHost.NewTabSpec("albums");
spec.SetIndicator("Albums",
Resources.GetDrawable(Resource.Drawable.ic_tab_artists));
spec.SetContent(intent);
TabHost.AddTab(spec);

TabHost.CurrentTab = 1;
}
}

[Activity(Label = "deneme2", MainLauncher = true)]
public class AlbumsActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

TextView textview = new TextView(this);
textview.Text = "This is the Albums tab";
SetContentView(textview);

}
}

   [Activity(Label = "deneme2", MainLauncher = true, Theme =
"@android:style/Theme.NoTitleBar")]
public class ArtistsActivity : Activity
{
//int count = 1;
WebView web_view;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);

SetContentView(Resource.Layout.Main);
web_view = new WebView(this);
web_view = FindViewById(Resource.Id.webview);
web_view.Settings.JavaScriptEnabled = true;
web_view.LoadUrl("http://www.google.com";);
web_view.SetWebViewClient(new HelloWebViewClient());

}

private class HelloWebViewClient : WebViewClient
{
public override bool ShouldOverrideUrlLoading(WebView
view, string url)
{
view.LoadUrl(url);
return true;
}
}
}

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


Re: [android-developers] webview in tabs

2011-03-23 Thread TreKing
On Tue, Mar 22, 2011 at 6:40 AM, seyma  wrote:

> SetContentView(Resource.Layout.Main);
>web_view = new WebView(this);
>web_view = FindViewById(Resource.Id.webview);
>web_view.Settings.JavaScriptEnabled = true;
>web_view.LoadUrl("http://www.google.com";);
>web_view.SetWebViewClient(new HelloWebViewClient());
>


You load some layout, create a WebView dynamically, then do nothing with it.
How do you expect it to show up if you don't add it to your layout!?

-
TreKing  - Chicago
transit tracking app for Android-powered devices

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