0% found this document useful (0 votes)
15 views4 pages

Practical14 Mad

The document describes an Android application that uses an ImageView to display images and a button to change the image. It includes Java code to initialize the ImageView and button, set an onclick listener for the button to change the image, and XML layout files defining the user interface.

Uploaded by

Vaibhav Hoke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

Practical14 Mad

The document describes an Android application that uses an ImageView to display images and a button to change the image. It includes Java code to initialize the ImageView and button, set an onclick listener for the button to change the image, and XML layout files defining the user interface.

Uploaded by

Vaibhav Hoke
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

2)Imageview

package com.example.exp14;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

public class MainActivityextends AppCompatActivity {


Button button;
ImageViewimageView;

@Override

protected void onCreate(Bundle savedInstanceState) {


super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
button=findViewById(R.id.button);
imageView=findViewById(R.id.image);

}
public void Changeimg(View view)
{
imageView.setImageResource(R.drawable.pic1);
}
}

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayoutxmlns: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"
tools:context=".MainActivity">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/image"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:src="@drawable/ic_launcher_foreground"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/button"
android:text="change"
android:textSize="15dp"
android:onClick="Changeimg"
android:layout_below="@+id/image"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
/>

</RelativeLayout>

<?xml version="1.0" encoding="utf-8"?>


<RelativeLayoutxmlns: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"
tools:context=".MainActivity">

<TextView
android:id="@+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="vertical scrollview"
android:layout_centerHorizontal="true"
android:textSize="30dp"
android:textStyle="bold"
/>

<ScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_below="@+id/text"
android:scrollbars="vertical"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sania"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Riddi"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Sneha"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Siddhi"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Tulshi"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Pallavi"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Rutuja"
android:textSize="20dp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Payal"
android:textSize="20dp"
android:textStyle="bold"/>
</LinearLayout>
</ScrollView>
</RelativeLayout>

You might also like