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

Kotlin

This document contains code for an Android activity written in Kotlin that allows a user to update date and other data in a SQLite database. It initializes bindings and views, sets an onClick listener for a button to open a date picker dialog, and another onClick listener to insert the updated data into the database and clear the views.

Uploaded by

Carlos BP
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Kotlin

This document contains code for an Android activity written in Kotlin that allows a user to update date and other data in a SQLite database. It initializes bindings and views, sets an onClick listener for a button to open a date picker dialog, and another onClick listener to insert the updated data into the database and clear the views.

Uploaded by

Carlos BP
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

package com.example.

reloj

import android.app.DatePickerDialog
import android.content.ContentValues
import android.os.Bundle
import android.widget.TextView
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import com.example.reloj.databinding.ActivityActualizaBinding
import kotlinx.android.synthetic.main.activity_actualiza.*
import java.util.*

class actualiza : AppCompatActivity() {


lateinit var binding1: ActivityActualizaBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding1=DataBindingUtil.setContentView(this,R.layout.activity_actualiza)
//setContentView(R.layout.activity_actualiza)
//supportActionBar!!.title="Candado 2"
//supportActionBar!!.setIcon(R.drawable.candado)
//supportActionBar!!.setDisplayHomeAsUpEnabled(true)
//supportActionBar!!.setDisplayUseLogoEnabled(true)
//et0.text=getIntent().getStringExtra("ET0")
//titulo.text="ACTUALIZACION"
//textView2.text="ID"

//val bundle1 = intent.extras


//val dato=bundle1?.getString("et0")
//val dato1=bundle?.getString("ET1")
//val dato2=bundle?.getString("ET2")
// var dato3=bundle?.getString("ET3")
// var dato4=bundle?.getString("ET4")
//et0.text=dato
//et1.setText(dato1)
//et1.setText(dato2)
// et1.setText(dato3)
// et1.setText(dato4)

val c = Calendar.getInstance()
val year=c.get(Calendar.YEAR)
val mes=c.get(Calendar.MONTH)
val dia=c.get(Calendar.DAY_OF_MONTH)
imgbtn1.setOnClickListener {
val dpd= DatePickerDialog(this,DatePickerDialog.OnDateSetListener
{view, mYear, mMonth, mDay ->
et1.setText(""+ mDay +"/"+ mMonth +"/"+ mYear)},year,mes,dia)
dpd.show()
}

grabar.setOnClickListener {
val admin = AdminSQliteOpenHelper(this,"administracion", null, 1)
val bd = admin.writableDatabase
val registro = ContentValues()
var cod="1"
//registro.put("fecha", et1.getText().toString())
//registro.put("detalle", et2.getText().toString())
//registro.put("ingreso", et3.getText().toString())
//registro.put("salida", et4.getText().toString())

//bd.update("consumo",cod , registro)
//bd.update()
bd.close()

et1.setText("")
et2.setText("")
et3.setText("")
et4.setText("")
Toast.makeText(this, "Se cargaron los datos",
Toast.LENGTH_SHORT).show()
}

}
}

You might also like