mirror of
https://github.com/lacerta-doc/Lacerta.git
synced 2024-11-26 17:53:14 +00:00
InputDialogのWrapper作成 WIP
This commit is contained in:
parent
281238a38e
commit
301fab8024
|
@ -0,0 +1,28 @@
|
||||||
|
package one.nem.lacerta.utils;
|
||||||
|
|
||||||
|
import android.app.AlertDialog;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.DialogInterface;
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
|
public class TextInputDialog {
|
||||||
|
public static CompletableFuture<String> show(Context context, String title, String message, String defaultValue, String positiveButton, String negativeButton) {
|
||||||
|
return CompletableFuture.supplyAsync(() -> {
|
||||||
|
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||||
|
builder.setTitle(title);
|
||||||
|
builder.setMessage(message);
|
||||||
|
final android.widget.EditText input = new android.widget.EditText(context);
|
||||||
|
input.setText(defaultValue);
|
||||||
|
builder.setView(input);
|
||||||
|
builder.setPositiveButton(positiveButton, (dialog, which) -> {
|
||||||
|
dialog.dismiss();
|
||||||
|
});
|
||||||
|
builder.setNegativeButton(negativeButton, (dialog, which) -> {
|
||||||
|
dialog.cancel();
|
||||||
|
});
|
||||||
|
builder.show();
|
||||||
|
return input.getText().toString();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user