Last active
May 14, 2018 07:22
-
-
Save tonY1883/a650a0978979224345637540d979b769 to your computer and use it in GitHub Desktop.
Android number picker dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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" | |
android:layout_marginBottom="4dp" | |
android:layout_marginLeft="4dp" | |
android:layout_marginRight="4dp" | |
android:layout_marginTop="16dp" | |
android:orientation="vertical"> | |
<NumberPicker | |
android:id="@+id/picker" | |
android:layout_width="wrap_content" | |
android:layout_height="wrap_content" | |
android:layout_centerHorizontal="true"/> | |
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void showPickerDialog() { | |
AlertDialog.Builder builder = new AlertDialog.Builder(this); | |
final View view = this.getLayoutInflater().inflate(R.layout.dialog_picker, null); | |
builder.setView(view); | |
//builder.setTitle(); | |
final NumberPicker picker = (NumberPicker) view.findViewById(R.id.picker); | |
//picker.setMinValue(); | |
//picker.setMaxValue(); | |
//picker.setValue(); | |
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int id) { | |
//positive button action | |
} | |
}) | |
.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { | |
@Override | |
public void onClick(DialogInterface dialog, int id) { | |
//negative button action | |
} | |
}); | |
builder.create().show(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment