java打开输入框,java – 在Android中打开输入对话框

我想在某个点打开一个输入对话框,我可以在其输入后存储和使用它.

我在互联网上找到的所有例子都非常先进,我想它们并不像我想要的那样简单 – 我只需要类似于Java的东西:

String name = JOptionPane.showInputDialog("Enter your name");

保留输入以供以后计算对我来说也很重要.

先感谢您.

解决方法:

请尝试以下代码段. Main.this是活动参考.

// Set an EditText view to get user input

final EditText input = new EditText(Main.this);

new AlertDialog.Builder(Main.this)

.setTitle("Update Status")

.setMessage(message)

.setView(input)

.setPositiveButton("Ok", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int whichButton) {

editable = input.getText();

// deal with the editable

}

})

.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

public void onClick(DialogInterface dialog, int whichButton) {

// Do nothing.

}

}).show();

标签:java,android

来源: https://codeday.me/bug/20190614/1237383.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值