2013-05-07 1 views
4

나는 안드로이드 개발에 대한 멍청한 놈이야. 그리고 뷰의 특정 좌표에 NewQuickAction3D 팝업 대화 상자를 표시하는 방법을 알아 내려고하고있다. 나는 팝업을 this 튜토리얼과 통합하고 있습니다. 본질적으로, 팝업 대화 상자를 사용하여 사용자가 "infoview"를 사용하여 캔버스에 그림을 그려 터치하는 데이터를 표시하려고합니다. 현재 팝업은 상단에 앵커 뷰의 중심 인 &을 표시합니다. 어떻게하면 특정 좌표를 표시 할 수 있습니까? 어떤 도움이라도 대단히 감사합니다.특정 좌표에서 사용자 지정 대화 상자를 배치하는 방법은 무엇입니까?

MY 코드

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 

편집

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); 
} 

답변

9

무시보기

에 AlertDialog 대화의 onTouch();

@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(); 
    } 

사용자가 화면을 터치하는 경우에도 대화 상자가 표시됩니다. 그래서 움직이면서 대화를 닫는다.

+0

응답 해 주셔서 감사합니다. 당신의 대답에 약간의 문제가 있습니다. NewQuickAction은 사용자 정의 대화 상자이므로 창 속성을 가져올 수 없습니다. 이견있는 사람? –

+0

활동 클래스의 사용자 정의보기 내부 클래스 만들기 – Raghunandan

관련 문제