在否决重复投票之前,请检查我到目前为止所做的尝试。
我试图关闭外部触摸的弹出窗口。我已经尝试了所有可用的解决方案,但它不起作用。
第一次尝试:
pwindo.setBackgroundDrawable(new BitmapDrawable());
pwindo.setFocusable(true);
pwindo.setOutsideTouchable(true);
第二次尝试:
pwindo.setBackgroundDrawable(new ColorDrawable());
pwindo.setFocusable(true);
pwindo.setOutsideTouchable(true);
第三次尝试:
pwindo.setBackgroundDrawable(new ColorDrawable());
pwindo.setFocusable(true);
pwindo.setOutsideTouchable(false);
第四次尝试:
pwindo.setFocusable(true);
pwindo.setOutsideTouchable(false);
第五次尝试:
pwindo.setOutsideTouchable(true);
第六次尝试:
pwindo.setOutsideTouchable(false);
第七次尝试:
pwindo.setFocusable(true);
没有任何工作。
更新:
public void addFlyout()
{
try {
LayoutInflater inflater = TabActivity.this.getLayoutInflater();
Display display = getWindowManager().getDefaultDisplay();
Method mGetRawH = Display.class.getMethod("getRawHeight");
Method mGetRawW = Display.class.getMethod("getRawWidth");
int rawHeight = (Integer) mGetRawH.invoke(display);
View view = inflater.inflate(R.layout.flyout_list_layout,
(ViewGroup) findViewById(R.id.flyoutLayoutList));
Dialog dialog = new Dialog(TabActivity.this);
pwindo = new PopupWindow(view, 340, rawHeight- actionBar.getHeight(), true);
pwindo.showAtLocation(view, Gravity.RIGHT | Gravity.TOP, 0, actionBar.getHeight());
pwindo.setBackgroundDrawable(new ColorDrawable(Color.RED));
// pwindo.setTouchable(true);
pwindo.setOutsideTouchable(true);
pwindo.setTouchInterceptor(new View.OnTouchListener() {
@Override public boolean onTouch(View v, MotionEvent event)
{
if (event.getAction() == MotionEvent.ACTION_OUTSIDE)
{
pwindo.dismiss();
//Log.e(TAG, "some event happened outside window: action outside");
return true;
}
// Log.e(TAG, "some event happened outside window");
return false;
}
});
listFlyout = (ListView) view.findViewById(R.id.list_slideList);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(TabActivity.this, R.layout.drawer_item, R.id.content, tabs);
listFlyout.setAdapter(adapter);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
和
@Override
public void onTabSelected(ActionBar.Tab tab, FragmentTransaction fragmentTransaction) {
// When the given tab is selected, switch to the corresponding page in
// the ViewPager.
try {
if(tab.getPosition() == 4)
{
addFlyout();
}
else
mViewPager.setCurrentItem(tab.getPosition());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}