i want to to click on More option menu item in my navigation view to open a webpage it may be "www.google.com" i have searched it like its work on Button click n tried to implement it but it does't work it may be a silly questioned and asked before but i did't find any quite well answer for it
here is my More app fragment
import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.webkit.WebView; import android.widget.Button; import android.widget.TextView; public class MoreApps extends Fragment { private WebView webView1; Button google; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final TextView textView = new TextView(getActivity()); textView.setText(R.string.hello_blank_fragment); return textView; google = (Button) textView.findViewById(R.id.google); google.setOnClickListener(new View.OnClickListener() { public void onClick(View arg0) { webView1 = (WebView) textView.findViewById(R.id.webView); webView1.getSettings().setJavaScriptEnabled(true); webView1.loadUrl("http://www.google.co.in/"); } }); } }
menu.xml
<?xml version="1.0" encoding="utf-8"?> <menu xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"> <group android:checkableBehavior="single"> <item android:title="share" app:showAsAction="always" android:id="@+id/action_share" android:orderInCategory="100" android:actionProviderClass="android.widget.ShareActionProvider"/> <item android:id="@+id/home_id" android:title="Home" android:icon="@drawable/person" ></item> <item android:id="@+id/message_id" android:title="Fat Calculator" android:icon="@drawable/person" ></item> <item android:id="@+id/setting_id" android:title="Food" android:icon="@drawable/person" ></item> <item android:id="@+id/storage_id" android:title="Storage" android:icon="@drawable/person" ></item> </group> <item android:title="Social"> <menu> <item android:title="Rate Us" android:id="@+id/rate_id" android:icon="@drawable/rate" ></item> <item android:title="More Apps" android:id="@+id/more_id" android:icon="@drawable/more" ></item> </menu> </item> </menu>
No comments:
Post a Comment