我已经使用绘制视图实现了自定义对话框...如何从对话框中获取图像视图上的绘制视图

时间:2016-07-23 09:16:10

标签: java android

我创建了一个小应用程序,在主活动中有一个图像视图和一个按钮。按钮点击对话框打开,用户可以在画布上绘制任何东西。现在我想将此画布设置在我的主屏幕图像视图中如何设置?请参阅图像

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:0)

在您的活动中这样做

AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
LayoutInflater inflater = this.getLayoutInflater();
View dialogView = inflater.inflate(R.layout.yourcustomview, null);//add your view from drawable folder
dialogBuilder.setView(dialogView);

EditText editText = (EditText) dialogView.findViewById(R.id.editText);//view from custom dialog
editText.setText("test");
AlertDialog alertDialog = dialogBuilder.create();
alertDialog.show();

修改:使用android:background="@drawable/your_custom_dialog"

在xml代码中设置您的imageview drawble
相关问题