2016-05-20 36 views

回答

1

您可以使用PopupWindow然後用popupWindow.showAsDropDown(theView)。

編輯: 這是從我的代碼示例:

LayoutInflater inflater = (LayoutInflater) TimeCheckActivity.this 
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    View layout = inflater.inflate(R.layout.timecheck_popup, 
      (ViewGroup) findViewById(R.id.popup_element)); 
    popupWindow = new PopupWindow(layout, 320, 160, true); 
    popupWindow.setBackgroundDrawable(new BitmapDrawable()); 
    popupWindow.setOutsideTouchable(true); 

    radioButton[1].setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      if(times.size()>1) { 
       popupText.setText(times.get(1).toString()); 
       popupWindow.showAsDropDown((View) radioButton[1]); 

      } 
      return true; 
     } 
    }); 

我也有具有的TextView( 「popupText」)的XML佈局。

+0

不能正常工作。可以分享一些鏈接或代碼。 –

+0

@SagarGawawane我編輯了我的答案。覈實。 –

+0

感謝它的工作。 –