0

我需要帮助将值从自定义对话框传递到活动。我不明白我应该使用什么。我已经使用过意图,但对话框不支持意图值传递。所以任何人都可以在这里帮助我,我完全被困住了。如果你有任何基本的例子,那就太好了。谢谢你。

4

1 回答 1

0

来自谷歌文档的片段:

// 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)
}
于 2013-03-18T11:25:01.700 回答