Advertisement
Guest User

Untitled

a guest
Sep 11th, 2015
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. package ge.msinfo.msinfo;
  2.  
  3. import android.content.Intent;
  4. import android.net.Uri;
  5. import android.os.Bundle;
  6. import android.support.design.widget.FloatingActionButton;
  7. import android.support.design.widget.Snackbar;
  8. import android.support.v7.app.AppCompatActivity;
  9. import android.support.v7.widget.Toolbar;
  10. import android.view.View;
  11. import android.view.Menu;
  12. import android.view.MenuItem;
  13. import android.webkit.WebView;
  14. import android.webkit.WebViewClient;
  15.  
  16. public class MainActivity extends AppCompatActivity {
  17. public boolean shouldOverrideUrlLoading(WebView view, String url) {
  18. if (url != null && url.startsWith("http://www.msinfo.ge/")) {
  19. view.getContext().startActivity(
  20. new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
  21. return true;
  22. } else {
  23. return false;
  24. }
  25. }
  26.  
  27. @Override
  28. protected void onCreate(Bundle savedInstanceState) {
  29. super.onCreate(savedInstanceState);
  30. setContentView(R.layout.activity_main);
  31. WebView myWebView = (WebView) findViewById(R.id.webview);
  32. myWebView.loadUrl("http://www.msinfo.ge/");
  33. Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  34. setSupportActionBar(toolbar);
  35.  
  36. FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  37. fab.setOnClickListener(new View.OnClickListener() {
  38. @Override
  39. public void onClick(View view) {
  40. Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
  41. .setAction("Action", null).show();
  42. }
  43. });
  44. }
  45.  
  46. @Override
  47. public boolean onCreateOptionsMenu(Menu menu) {
  48. // Inflate the menu; this adds items to the action bar if it is present.
  49. getMenuInflater().inflate(R.menu.menu_main, menu);
  50. return true;
  51. }
  52.  
  53. @Override
  54. public boolean onOptionsItemSelected(MenuItem item) {
  55. // Handle action bar item clicks here. The action bar will
  56. // automatically handle clicks on the Home/Up button, so long
  57. // as you specify a parent activity in AndroidManifest.xml.
  58. int id = item.getItemId();
  59.  
  60. //noinspection SimplifiableIfStatement
  61. if (id == R.id.action_settings) {
  62. return true;
  63. }
  64.  
  65. return super.onOptionsItemSelected(item);
  66. }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement