Mam zrobione menu + webView na całą przestrzeń roboczą. Każdy przycisk przekazuje do webView urla z daną www. Stworzyłem akcje dla przycisków w ten sposób:
public class MainActivity : Activity
{
WebView web_view;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
//Set our custom view
ActionBar.SetCustomView(Resource.Layout.action_bar);
ActionBar.SetDisplayShowCustomEnabled(true);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
web_view = FindViewById<WebView> (Resource.Id.webView1);
web_view.Settings.JavaScriptEnabled = true;
web_view.LoadUrl ("http://www.onet.pl");
web_view.SetWebViewClient (new HelloWebViewClient ());
LinearLayout linTest = (LinearLayout)ActionBar.CustomView.FindViewById<LinearLayout>(Resource.Id.linearLayout1);
LinearLayout linTest2 = (LinearLayout)ActionBar.CustomView.FindViewById<LinearLayout>(Resource.Id.linearLayout2);
LinearLayout linTest3 = (LinearLayout)ActionBar.CustomView.FindViewById<LinearLayout>(Resource.Id.linearLayout3);
LinearLayout linTest4 = (LinearLayout)ActionBar.CustomView.FindViewById<LinearLayout>(Resource.Id.linearLayout4);
linTest.Click += linTest_Click;
linTest2.Click += linTest2_Click;
linTest3.Click += linTest3_Click;
linTest4.Click += linTest4_Click;
LinearLayout linearLayout = view.FindViewById<LinearLayout>(Resource.Id.linearLayout1);
}
void linTest_Click(object sender, EventArgs e) {
//ur code here
web_view.LoadUrl ("http://www.onet.pl");
}
void linTest2_Click(object sender, EventArgs e) {
//ur code here
web_view.LoadUrl ("http://www.wp.pl");
}
void linTest3_Click(object sender, EventArgs e) {
//ur code here
web_view.LoadUrl ("http://www.interia.pl");
}
void linTest4_Click(object sender, EventArgs e) {
//ur code here
web_view.LoadUrl ("http://www.google.pl");
}
public override bool ShouldOverrideUrlLoading (WebView view, string url)
{
view.LoadUrl (url);
return false;
}
I wszystko by fajnie działało tylko url jest przekazywany dopiero przy DRUGIM kliknięciu jak już ikona jest podświetlona. W czym może być problem?
Poniżej poglądowy screen+logi: