List of usage examples for android.webkit WebView loadUrl
public void loadUrl(String url)
From source file:net.oremland.rss.reader.fragments.BrowserFragment.java
private void loadUrl() { String base64Data = Base64.encodeToString(getFeedItem().getContent().getBytes(), Base64.DEFAULT); String dataUri = String.format("data:text/html;charset=utf-8;base64,%s", base64Data); WebView description = (WebView) getView().findViewById(R.id.description); description.loadUrl(dataUri); }
From source file:org.namelessrom.devicecontrol.modules.about.LicenseFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_webview, container, false); final WebView wv = (WebView) view.findViewById(R.id.dialog_help_webview); wv.getSettings().setTextZoom(90);// w w w . j a v a 2s.c om final String url = AppResources.get().isDarkTheme() ? "file:///android_asset/license_dark.html" : "file:///android_asset/license.html"; wv.loadUrl(url); return view; }
From source file:org.namelessrom.devicecontrol.modules.about.PrivacyFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.fragment_webview, container, false); final WebView wv = (WebView) view.findViewById(R.id.dialog_help_webview); wv.getSettings().setTextZoom(90);// ww w.j a v a 2 s. c o m final String url = AppResources.get().isDarkTheme() ? "file:///android_asset/privacy_dark.html" : "file:///android_asset/privacy.html"; wv.loadUrl(url); return view; }
From source file:io.github.hidroh.materialistic.SubmitActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { onBackPressed();/*from w w w . jav a 2s . c o m*/ return true; } if (item.getItemId() == R.id.menu_send) { if (!validate()) { return true; } final boolean isUrl = isUrl(mContentEditText.getText().toString()); mAlertDialogBuilder.init(SubmitActivity.this) .setMessage(isUrl ? R.string.confirm_submit_url : R.string.confirm_submit_question) .setPositiveButton(android.R.string.ok, (dialog, which) -> submit(isUrl)) .setNegativeButton(android.R.string.cancel, null).create().show(); return true; } if (item.getItemId() == R.id.menu_guidelines) { WebView webView = new WebView(this); webView.loadUrl(HN_GUIDELINES_URL); mAlertDialogBuilder.init(this).setView(webView).setPositiveButton(android.R.string.ok, null).create() .show(); } return super.onOptionsItemSelected(item); }
From source file:com.rizal.lovins.smartkasir.fragment.HomeAdminFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override// www.j a v a2 s. c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_home_admin, container, false); WebView mWebView = (WebView) view.findViewById(R.id.webViewAdmin); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.getSettings().setBuiltInZoomControls(false); mWebView.getSettings().setDisplayZoomControls(false); mWebView.loadUrl("file:///android_asset/license/index.html"); return view; }
From source file:com.rizal.lovins.smartkasir.fragment.HomeKasirFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from ww w. jav a2 s. c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_home_kasir, container, false); WebView mWebView = (WebView) view.findViewById(R.id.webViewKasir); WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); mWebView.getSettings().setBuiltInZoomControls(false); mWebView.getSettings().setDisplayZoomControls(false); mWebView.loadUrl("file:///android_asset/license/index_kasir.html"); return view; }
From source file:at.alladin.rmbt.android.terms.RMBTCheckFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { if (!(getActivity() instanceof RMBTMainActivity)) firstTime = false;//w ww . jav a 2 s . c o m final View v = inflater.inflate(R.layout.ndt_check, container, false); if (!firstTime) v.findViewById(R.id.termsNdtButtonBack).setVisibility(View.GONE); final TextView textTitle = (TextView) v.findViewById(R.id.check_fragment_title); textTitle.setText(checkType.getTitleId()); checkBox = (CheckBox) v.findViewById(R.id.ndtCheckBox); checkBox.setText(checkType.getTextId()); if (savedInstanceState != null) { checkBox.setChecked(savedInstanceState.getBoolean("isChecked")); } else { checkBox.setChecked(checkType.isDefaultIsChecked()); } final Button buttonAccept = (Button) v.findViewById(R.id.termsNdtAcceptButton); if (!firstTime) { checkBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { buttonAccept.setEnabled(isChecked); } }); } final WebView wv = (WebView) v.findViewById(R.id.ndtInfoWebView); wv.loadUrl(checkType.getTemplateFile()); buttonAccept.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final FragmentActivity activity = getActivity(); switch (checkType) { case NDT: ConfigHelper.setNDT(activity, checkBox.isChecked()); ConfigHelper.setNDTDecisionMade(activity, true); break; case LOOP_MODE: ConfigHelper.setLoopMode(activity, checkBox.isChecked()); break; } activity.getSupportFragmentManager().popBackStack(checkType.getFragmentTag(), FragmentManager.POP_BACK_STACK_INCLUSIVE); if (firstTime && CheckType.NDT.equals(checkType)) { ((RMBTMainActivity) activity).initApp(false); } else { getActivity().setResult(checkBox.isChecked() ? Activity.RESULT_OK : Activity.RESULT_CANCELED); getActivity().finish(); } } }); new Handler().postDelayed(new Runnable() { @Override public void run() { buttonAccept.setEnabled(firstTime || checkBox.isChecked()); } }, 500); final Button buttonBack = (Button) v.findViewById(R.id.termsNdtBackButton); buttonBack.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { getActivity().getSupportFragmentManager().popBackStack(); } }); return v; }
From source file:com.mario22gmail.license.nfc_project.FragmentBrowser.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.fragment_browser, container, false); mWebview = (WebView) v.findViewById(R.id.webViewFb); Intent myIntent = new Intent("fragment.setTitle"); myIntent.putExtra("Title", "Browser"); NavigationDrawerActivity.getAppContext().sendBroadcast(myIntent); urlEditText = (EditText) v.findViewById(R.id.searchForGoogle); EditTextFocusChangeListner textLisner = new EditTextFocusChangeListner(getContext(), R.id.searchForGoogle); urlEditText.setOnFocusChangeListener(textLisner); urlEditText.setSingleLine();/* w w w . jav a 2s. c o m*/ urlEditText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_DONE) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); String query = urlEditText.getText().toString(); if (!query.isEmpty()) { String url = "https://www.google.com/search?q=" + query; mWebview.loadUrl(url); mWebview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); } } return true; } }); final Button searchButton = (Button) v.findViewById(R.id.searchOnGoogleButton); searchButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { InputMethodManager imm = (InputMethodManager) getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(v.getWindowToken(), 0); String query = urlEditText.getText().toString(); if (!query.isEmpty()) { String url = "https://www.google.com/search?q=" + query; mWebview.loadUrl(url); mWebview.setWebViewClient(new WebViewClient() { public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); } } }); if (!js.equals("") && !url.equals("")) { OpenWebSite(url, js); Log.i("nfc_debug", "A trecut"); } return v; // inflater.inflate(R.layout.fragment_browser, container, false); }
From source file:com.example.android.navigationdrawer.AboutUs.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.aboutus);//from w w w.jav a 2 s. co m WebView wv = (WebView) findViewById(R.id.aboutwebview); wv.loadUrl("http://202.125.255.1/finaltruetonev1/index.php/user/guestAbout"); WebSettings webSettings = wv.getSettings(); webSettings.setJavaScriptEnabled(true); mTitle = mDrawerTitle = getTitle(); mPlanetTitles = getResources().getStringArray(R.array.planets_array); mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); mDrawerList = (RecyclerView) findViewById(R.id.left_drawer); // set a custom shadow that overlays the main content when the drawer opens // mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START); // improve performance by indicating the list if fixed size. mDrawerList.setHasFixedSize(true); mDrawerList.setLayoutManager(new LinearLayoutManager(this)); // set up the drawer's list view with items and click listener mDrawerList.setAdapter(new PlanetAdapter(mPlanetTitles, this)); // enable ActionBar app icon to behave as action to toggle nav drawer getActionBar().setDisplayHomeAsUpEnabled(true); getActionBar().setHomeButtonEnabled(true); // ActionBarDrawerToggle ties together the the proper interactions // between the sliding drawer and the action bar app icon mDrawerToggle = new ActionBarDrawerToggle(this, /* host Activity */ mDrawerLayout, /* DrawerLayout object */ R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */ R.string.drawer_open, /* "open drawer" description for accessibility */ R.string.drawer_close /* "close drawer" description for accessibility */ ) { public void onDrawerClosed(View view) { getActionBar().setTitle(mTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } public void onDrawerOpened(View drawerView) { getActionBar().setTitle(mDrawerTitle); invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu() } }; mDrawerLayout.setDrawerListener(mDrawerToggle); if (savedInstanceState == null) { selectItem(2); } }
From source file:org.gots.ui.WebViewActivity.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { WebView mWebView = new WebView(getActivity()); mWebView.setWebViewClient(new HelloWebViewClient()); mWebView.getSettings().setJavaScriptEnabled(true); Bundle bundle = this.getArguments(); String url = bundle.getString("org.gots.seed.url"); mWebView.loadUrl(url); pd = ProgressDialog.show(getActivity(), "", getResources().getString(R.string.gots_loading), true); pd.setCanceledOnTouchOutside(true);//from www.ja v a 2s . c o m return mWebView; }