0% found this document useful (0 votes)
4 views

Practical 9

Uploaded by

Ansari Arman
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)
4 views

Practical 9

Uploaded by

Ansari Arman
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

Practical 9

<?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:orientation="vertical"

tools:context=".MainActivity">

<TextView

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="Bluetooth"

app:layout_constraintBottom_toBottomOf="parent"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

app:layout_constraintTop_toTopOf="parent"

android:layout_gravity="center"

android:paddingTop="100dp"

android:textSize="25dp"

app:layout_constraintVertical_bias="0.146" />

<ToggleButton
android:id="@+id/tb1"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_gravity="center"

android:text="Bluetooth"

app:layout_constraintEnd_toEndOf="parent"

app:layout_constraintStart_toStartOf="parent"

tools:layout_editor_absoluteY="209dp" />

<TextView

android:id="@+id/tvi1"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:textSize="25dp"

android:text="Bluetooth" />

</LinearLayout>

JAVA

package com.example.pr7;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;

import android.view.View;

import android.widget.TextView;

import android.widget.ToggleButton;

public class MainActivity extends AppCompatActivity {

ToggleButton t1;
TextView tv1;

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

t1=(ToggleButton) findViewById(R.id.tb1);

tv1=(TextView) findViewById(R.id.tvi1);

t1.setOnClickListener(new View.OnClickListener() {

@Override

public void onClick(View view) {

tv1.setText("Bluetooth "+t1.getText().toString());

});

You might also like