Android TimePicker Example









// ata sub ar work tar mane amora calculator make korte parbo

package com.example.myapplication;

import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.TextView;
import android.widget.TimePicker;


public class MainActivity extends AppCompatActivity {


    private TextView textView;
    private Button button;
    private TimePicker timepicker;

    @Override    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = this.<TextView>findViewById(R.id.textid2);
        button = this.<Button>findViewById(R.id.buttonid);
       timepicker = this.<TimePicker>findViewById(R.id.timepicker);

      textView.setText(currenttime());

      button.setOnClickListener(new View.OnClickListener() {
          @Override          public void onClick(View v) {

              textView.setText(currenttime());
          }
      });

    }
       String currenttime (){

    StringBuilder stringBuilder = new StringBuilder();
    stringBuilder.append(timepicker.getCurrentHour()+ "  : "+ timepicker.getCurrentMinute() );



        return stringBuilder.toString();

    }
}

Produk Kami Lainnya :

Post a Comment

 
ibs(idblogsite)
Copyright © 2014. Background remove
Distributed By Blog Templates | Designed By Gusti Adnyana