Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. package com.example.babuassignment;
  2.  
  3.  
  4. import androidx.appcompat.app.AppCompatActivity;
  5.  
  6. import android.annotation.SuppressLint;
  7. import android.os.Bundle;
  8. import android.view.View;
  9. import android.webkit.WebSettings;
  10. import android.webkit.WebView;
  11. import android.widget.Toast;
  12.  
  13. public class MainActivity extends AppCompatActivity {
  14.  
  15. @SuppressLint("SetJavaScriptEnabled")
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_main);
  20.  
  21. WebView gView;
  22. gView = findViewById(R.id.webview);
  23.  
  24. gView.loadUrl("https://www.google.com");
  25. WebSettings webSettings = gView.getSettings();
  26. webSettings.setJavaScriptEnabled(true);
  27.  
  28. }
  29.  
  30. public void imageButtonClick(View view) {
  31. showToast("Mainuzzaman Babu");
  32. }
  33.  
  34. public void checkBox1Click(View view) {
  35. showToast("A is Selected");
  36. }
  37.  
  38. public void checkBox2Click(View view) {
  39. showToast("B is Selected");
  40. }
  41.  
  42. public void checkBox3Click(View view) {
  43. showToast("C is Selected");
  44. }
  45.  
  46. private void showToast(String msg) {
  47. Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
  48.  
  49. }
  50. }
  51.  
  52.  
  53.  
  54. ///
  55.  
  56.  
  57.  
  58. <?xml version="1.0" encoding="utf-8"?>
  59. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  60. xmlns:app="http://schemas.android.com/apk/res-auto"
  61. xmlns:tools="http://schemas.android.com/tools"
  62. android:layout_width="match_parent"
  63. android:layout_height="match_parent"
  64. android:gravity="center_horizontal"
  65. android:orientation="vertical"
  66. tools:context=".MainActivity">
  67.  
  68. <ImageButton
  69. android:layout_width="150dp"
  70. android:layout_height="150dp"
  71. android:layout_marginTop="24dp"
  72. android:onClick="imageButtonClick"
  73. android:scaleType="centerCrop"
  74. android:src="@drawable/babu" />
  75.  
  76. <WebView
  77. android:id="@+id/webview"
  78. android:layout_width="match_parent"
  79. android:layout_height="0dp"
  80. android:layout_marginTop="16dp"
  81. android:layout_marginBottom="16dp"
  82. android:layout_weight="1" />
  83.  
  84. <CheckBox
  85. android:layout_width="wrap_content"
  86. android:layout_height="wrap_content"
  87. android:onClick="checkBox1Click"
  88. android:text="A" />
  89.  
  90. <CheckBox
  91. android:layout_width="wrap_content"
  92. android:layout_height="wrap_content"
  93. android:onClick="checkBox2Click"
  94. android:text="B" />
  95.  
  96. <CheckBox
  97. android:layout_width="wrap_content"
  98. android:layout_height="wrap_content"
  99. android:layout_marginBottom="16dp"
  100. android:onClick="checkBox3Click"
  101. android:text="C" />
  102.  
  103. </LinearLayout>
  104.  
  105.  
  106.  
  107. manifestote
  108. ///
  109. <uses-permission android:name="android.permission.INTERNET"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement