How to customize the Nougat TimePicker Dialog?

Viewed 49

How I can customize the Nougat TimePicker Dialog to Spinner Modo in Android Studio, in this version it seems that the TimePicker is embedded within the Androdid because it is no longer necessary to place it in the layout, it only has to be called by code, here is my MainActivity:

public class MainActivity extends AppCompatActivity {
TimePickerDialog picker;
EditText eText;
Button btnGet;
TextView tvw;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    tvw=(TextView)findViewById(R.id.textView1);
    eText=(EditText) findViewById(R.id.editText1);

    eText.setInputType(InputType.TYPE_NULL);
    eText.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            final Calendar cldr = Calendar.getInstance();
            int hour = cldr.get(Calendar.HOUR_OF_DAY);
            int minutes = cldr.get(Calendar.MINUTE);
              // time picker dialog
            picker = new TimePickerDialog(MainActivity.this,new TimePickerDialog.OnTimeSetListener() {
                        @Override
                        public void onTimeSet(TimePicker tp, int sHour, int sMinute) {
                            eText.setText(sHour + ":" + sMinute);
                        }
                    }, hour, minutes, true);
            picker.show();
        }
    });


    btnGet=(Button)findViewById(R.id.button1);
    btnGet.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            tvw.setText("Selected Time: "+ eText.getText());
        }
    });
}

}

Here is the Layout code:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent">

<EditText
    android:id="@+id/editText1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_marginLeft="100dp"
    android:layout_marginTop="150dp"
    android:ems="10"
    android:hint="Enter Time" />
<Button
    android:id="@+id/button1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/editText1"
    android:layout_marginLeft="100dp"
    android:text="Get Date" />

<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button1"
    android:layout_marginLeft="100dp"
    android:layout_marginTop="10dp"
    android:textStyle="bold"
    android:textSize="18dp"/>

I need a visualization of the TimePicker Dialog like this: enter image description here

0 Answers
Related