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();

    }
}

datepicker in android studio 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;


public class MainActivity extends AppCompatActivity {


    private TextView textView;
    private Button button;
    private DatePicker datePicker;

    @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);
        datePicker = this.<DatePicker>findViewById(R.id.datepickerid);

      textView.setText(current());

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

              textView.setText(current());
          }
      });

    }
       String current (){

        StringBuffer stringBuffer = new StringBuffer();

        stringBuffer.append(datePicker.getMonth()+1 +" \n");
        stringBuffer.append(datePicker.getDayOfMonth()+"\n");
        stringBuffer.append(datePicker.getYear());
        return stringBuffer.toString();

    }
}


SeekBar in android studio 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.widget.SeekBar;
import android.widget.TextView;
import android.widget.Toast;


public class MainActivity extends AppCompatActivity {

private SeekBar seekBar;

private TextView textView;

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

        seekBar = this.<SeekBar>findViewById(R.id.seekbr);
        textView = this.<TextView>findViewById(R.id.textbox);

        textView.setText(" value "+seekBar.getProgress()+" /n"+ seekBar.getMax());

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {


                textView.setText(" value "+progress+" / "+ seekBar.getMax());
            }

            @Override            public void onStartTrackingTouch(SeekBar seekBar) {
                Toast.makeText(MainActivity.this," value is incress",Toast.LENGTH_SHORT).show();

            }

            @Override            public void onStopTrackingTouch(SeekBar seekBar) {

                Toast.makeText(MainActivity.this," value is Decrease",Toast.LENGTH_SHORT).show();
            }
        });

    }
}

ratingbar in android studio 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.RatingBar;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    private RatingBar ratingBar;

    private TextView textView;



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

        ratingBar = this.<RatingBar>findViewById(R.id.ratingbar);
        textView = this.<TextView>findViewById(R.id.textbox);


        ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
            @Override
            public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {

                textView.setText(" value "+ rating);

            }
        });
    }
}

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