2

サムネイルをクリックすると、ポップアップ ウィンドウが開きます。メソッドでそれを却下したいのですonTouchが、問題はonTouchメソッドが呼び出されていないことです。どうすれば実行できますか? ポップアップ ウィンドウを閉じるにはどうすればよいですか?

私のコードは次のとおりです。

public void onItemImageClicked(View view)
{
    LinearLayout layout = (LinearLayout)     getLayoutInflater().inflate(R.layout.popup,null); 
    ImageView fullSizeImg = (ImageView) layout.findViewById(R.id.fullSizeImage);
    fullSizeImg.setImageBitmap(bitmap);
    fullSizeImg.setFocusable(false);
    Display display = getWindowManager().getDefaultDisplay(); 
    int deviceWidth = display.getWidth()-40; 
    int deviceHeight = display.getHeight()-70; 
    popupWindow = new PopupWindow(layout, deviceWidth, deviceHeight, true);
    // display the popup in the center
    popupWindow.showAtLocation(layout, Gravity.CENTER, 0, 0);
    popupWindow.getMaxAvailableHeight(new View(this));
    popupWindow.setFocusable(true);
    popupWindow.setTouchInterceptor(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            popupWindow.dismiss();
            return false;
        }
    });
    popupWindow.setTouchable(true);

}
4

2 に答える 2

1

これを試して

                View popupView = globalconstant.layoutInflater.inflate(R.layout.popup, null);  
                popupWindow = new PopupWindow(popupView,globalconstant.displayWidth-20,480,true);
                popupWindow.setOutsideTouchable(true);
                popupWindow.setBackgroundDrawable(new BitmapDrawable());

onClickEvent

popupWindow.showAtLocation(v, Gravity.CENTER, 0, 15);
于 2012-09-04T07:48:50.443 に答える