我如何定位自定义对话框在特定的坐标? [英] How Do I Position Custom Dialog at specific Coordinate?
问题描述
我是小白Android开发,我试图找出如何显示在特定的NewQuickAction3D弹出的对话框中查看坐标。我与整合这个弹出窗口教程。从本质上讲,我想用弹出的对话框中显示,其中用户触摸而不是使用InfoView的在画布上绘画的数据目前,弹出式窗口,在顶部和放大器;我固定它的视图的中心。我怎样才能使它显示特定的坐标?任何帮助是极大的AP preciated。
我的code
公共无效updateMsg(字符串t_info,浮t_x,浮t_y,诠释T_C){
infoView.updateInfo(t_info,t_x,t_y,T_C); // Infoview中油漆中,在一个特定的坐标
quickAction.show(InfoView的); //我如何使用t_x&放大器; t_y而不只是协调锚固的InfoView这里
修改
公共无效updateMsg(字符串t_info,浮t_x,浮t_y,诠释T_C){
infoView.updateInfo(t_info,t_x,t_y,T_C);
WindowManager.LayoutParams wmlp = quickAction.getWindow()的getAttributes()。 //错误及彼窗口属性
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; // x位置
wmlp.y = 100; // y位置
quickAction.show(InfoView的);
}
覆盖您的视图onTouch()
AlertDialog对话框;
@覆盖
公共布尔onTouchEvent(MotionEvent事件){
浮X = event.getX();
浮Y = event.getY();开关(event.getAction()){
案例MotionEvent.ACTION_DOWN: 的ShowDialog(); //显示对话框
打破;
案例MotionEvent.ACTION_MOVE:
如果(对话!= NULL)
dialog.dismiss();
// 做一点事
打破;
案例MotionEvent.ACTION_UP:
//做somethig
打破;
}
返回true;
}
公共无效的ShowDialog()
{ AlertDialog.Builder建设者=新AlertDialog.Builder(FingerPaintActivity.this);
对话框= builder.create();
dialog.setTitle(我的对话);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow()的getAttributes()。
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; // x位置
wmlp.y = 100; // y位置
dialog.show();
}
即使绘制用户触摸屏幕,然后还显示对话框。因此解雇移动对话框中。
I'm a noob to android development and I am trying to figure out how to display the NewQuickAction3D popup dialog at a specific coordinate in a view. I am integrating the popup with this tutorial. Essentially, I want to use the popup dialog to display data where the users touch instead painting on the canvas using "infoview" Currently, the popup displays at the top¢er of the view that I anchor it to. How can i make it display a particular coordinate? Any help is greatly appreciated.
MY CODE
public void updateMsg(String t_info, float t_x, float t_y, int t_c){
infoView.updateInfo(t_info, t_x, t_y, t_c); //Infoview paints to on a specific coordinate
quickAction.show(infoView); //How do I use the t_x & t_y coordinates here instead of just anchoring infoview
EDIT
public void updateMsg(String t_info, float t_x, float t_y, int t_c){
infoView.updateInfo(t_info, t_x, t_y, t_c);
WindowManager.LayoutParams wmlp = quickAction.getWindow().getAttributes(); //Error here getting window attributes
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; //x position
wmlp.y = 100; //y position
quickAction.show(infoView);
}
Override onTouch() of your view
AlertDialog dialog;
@Override
public boolean onTouchEvent(MotionEvent event) {
float x = event.getX();
float y = event.getY();
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
showDialog(); // display dialog
break;
case MotionEvent.ACTION_MOVE:
if(dialog!=null)
dialog.dismiss();
// do something
break;
case MotionEvent.ACTION_UP:
// do somethig
break;
}
return true;
}
public void showDialog()
{
AlertDialog.Builder builder = new AlertDialog.Builder(FingerPaintActivity.this);
dialog = builder.create();
dialog.setTitle("my dialog");
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
wmlp.gravity = Gravity.TOP | Gravity.LEFT;
wmlp.x = 100; //x position
wmlp.y = 100; //y position
dialog.show();
}
Even to draw user touches the screen then also dialog is displayed. so dismiss dialog in on move.
这篇关于我如何定位自定义对话框在特定的坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!