0
我需要帮助将自定义对话框中的值传递给活动。 我不明白我应该用什么。我已经使用了意图,但对话框不支持意图值传递。 所以任何人都可以在这里帮助我,我完全被困住了。如果你有任何基本的例子,那么这将是非常好的。 谢谢。我们如何将任何值(选定一个)从对话框传递给Android中的活动?
我需要帮助将自定义对话框中的值传递给活动。 我不明白我应该用什么。我已经使用了意图,但对话框不支持意图值传递。 所以任何人都可以在这里帮助我,我完全被困住了。如果你有任何基本的例子,那么这将是非常好的。 谢谢。我们如何将任何值(选定一个)从对话框传递给Android中的活动?
片段从谷歌文档:
// Alert Dialog code (mostly copied from the Android docs
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Pick a color");
builder.setItems(items, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int item) {
myFunction(item);
}
});
AlertDialog alert = builder.create();
// Now elsewhere in your Activity class, you would have this function
private void myFunction(int result){
// Now the data has been "returned" (as pointed out, that's not
// the right terminology)
}
您是否尝试过使用一个变量来存储值和值传递给方法,在对话框的d时间解雇,该对话框你可以使用意图内.. – Abx 2013-03-18 11:25:46
请你可以把你的错误代码放在这里? – 2013-03-18 11:26:39