Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.babuassignment;
- import androidx.appcompat.app.AppCompatActivity;
- import android.annotation.SuppressLint;
- import android.os.Bundle;
- import android.view.View;
- import android.webkit.WebSettings;
- import android.webkit.WebView;
- import android.widget.Toast;
- public class MainActivity extends AppCompatActivity {
- @SuppressLint("SetJavaScriptEnabled")
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- WebView gView;
- gView = findViewById(R.id.webview);
- gView.loadUrl("https://www.google.com");
- WebSettings webSettings = gView.getSettings();
- webSettings.setJavaScriptEnabled(true);
- }
- public void imageButtonClick(View view) {
- showToast("Mainuzzaman Babu");
- }
- public void checkBox1Click(View view) {
- showToast("A is Selected");
- }
- public void checkBox2Click(View view) {
- showToast("B is Selected");
- }
- public void checkBox3Click(View view) {
- showToast("C is Selected");
- }
- private void showToast(String msg) {
- Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
- }
- }
- ///
- <?xml version="1.0" encoding="utf-8"?>
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:gravity="center_horizontal"
- android:orientation="vertical"
- tools:context=".MainActivity">
- <ImageButton
- android:layout_width="150dp"
- android:layout_height="150dp"
- android:layout_marginTop="24dp"
- android:onClick="imageButtonClick"
- android:scaleType="centerCrop"
- android:src="@drawable/babu" />
- <WebView
- android:id="@+id/webview"
- android:layout_width="match_parent"
- android:layout_height="0dp"
- android:layout_marginTop="16dp"
- android:layout_marginBottom="16dp"
- android:layout_weight="1" />
- <CheckBox
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="checkBox1Click"
- android:text="A" />
- <CheckBox
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="checkBox2Click"
- android:text="B" />
- <CheckBox
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginBottom="16dp"
- android:onClick="checkBox3Click"
- android:text="C" />
- </LinearLayout>
- manifestote
- ///
- <uses-permission android:name="android.permission.INTERNET"/>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement