0% found this document useful (0 votes)
14 views3 pages

Mad13 1

The document contains an Android XML layout and Java code for a simple application with a progress bar, text view, and button. The layout defines a progress bar that updates its value when the button is clicked, incrementing from 0 to 100. The Java code handles the button click event to start a new thread that updates the progress bar and text view accordingly.

Uploaded by

sohamastane077
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)
14 views3 pages

Mad13 1

The document contains an Android XML layout and Java code for a simple application with a progress bar, text view, and button. The layout defines a progress bar that updates its value when the button is clicked, incrementing from 0 to 100. The Java code handles the button click event to start a new thread that updates the progress bar and text view accordingly.

Uploaded by

sohamastane077
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/ 3

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

>
app:layout_constraintTop_toTopOf="parent" />
<AbsoluteLayout
xmlns:android="http://schemas.android.com/a
pk/res/android"
<ProgressBar

xmlns:app="http://schemas.android.com/apk/r android:id="@+id/progressBar"
es-auto" style="?android:attr/progressBarStyle"

android:layout_width="61dp"
xmlns:tools="http://schemas.android.com/tools
" android:layout_height="60dp"

android:id="@+id/main" android:layout_x="175dp"

android:layout_width="match_parent" android:layout_y="261dp"

android:layout_height="match_parent"

tools:context=".MainActivity"> android:progress="1"

android:max="100"

<TextView android:indeterminate="true"/>

android:layout_width="186dp"

android:layout_height="wrap_content" <TextView

android:layout_x="113dp" android:id="@+id/textView"

android:layout_y="14dp" android:layout_width="130dp"

android:text="Progress Bar" android:layout_height="41dp"

android:textSize="30dp" android:layout_x="152dp"

android:layout_y="353dp"
app:layout_constraintBottom_toBottomOf="par
android:textSize="10dp" />
ent"

app:layout_constraintEnd_toEndOf="parent" <Button

android:id="@+id/button"
app:layout_constraintStart_toStartOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content" TextView txt;

android:layout_x="153dp" Handler hndl = new Handler();

android:layout_y="420dp" Button btn;

android:text="Start Progress" /> @Override

protected void onCreate(Bundle


savedInstanceState) {
</AbsoluteLayout>
super.onCreate(savedInstanceState);
package com.example.mad13prac;
setContentView(R.layout.activity_main);

pb=(ProgressBar)
import android.os.Bundle; findViewById(R.id.progressBar);
import android.os.Handler; txt=(TextView)
import android.view.View; findViewById(R.id.textView);

import android.widget.Button; btn=(Button) findViewById(R.id.button);

import android.widget.ProgressBar; btn.setOnClickListener(new


View.OnClickListener() {
import android.widget.TextView;
@Override

public void onClick(View v) {


import androidx.activity.EdgeToEdge;
i=pb.getProgress();
import
androidx.appcompat.app.AppCompatActivity; new Thread(new Runnable() {

import androidx.core.graphics.Insets; @Override

import androidx.core.view.ViewCompat; public void run() {

import while(i<100){
androidx.core.view.WindowInsetsCompat; i=i+1;

hndl.post(new Runnable() {
public class MainActivity extends @Override
AppCompatActivity {
public void run() {
ProgressBar pb;
pb.setProgress(i);
int i = 0;
txt.setText(i+"/"+pb.getMax());

});

try {

Thread.sleep(100);

}catch (InterruptedException e){

e.printStackTrace();

}).start();

});

You might also like