KEMBAR78
Button Logic | PDF
0% found this document useful (0 votes)
8 views1 page

Button Logic

This document contains a Kotlin code snippet for an Android application. It defines a MainActivity class that manages a TableLayout and a Button, allowing users to toggle the visibility of specific columns in the table. The button text changes based on the visibility state of the columns, switching between 'Show' and 'Hide'.

Uploaded by

pranjal shukla
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views1 page

Button Logic

This document contains a Kotlin code snippet for an Android application. It defines a MainActivity class that manages a TableLayout and a Button, allowing users to toggle the visibility of specific columns in the table. The button text changes based on the visibility state of the columns, switching between 'Show' and 'Hide'.

Uploaded by

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

package com.example.

myapplication

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.Button
import android.widget.TableLayout

class MainActivity : AppCompatActivity() {


var bool = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
fun submit (view: View){
val tblobj:TableLayout=findViewById<TableLayout>(R.id.tab1)
val btn:Button=findViewById(R.id.button2)
tblobj.setColumnCollapsed(1,bool)
tblobj.setColumnCollapsed(2,bool)
if(bool){
bool=false
btn.text="Show"

}
else{
bool=true
btn.text="Hide"
}
}
}

You might also like