如何在android的另一个弹出窗口中显示弹出窗口
我想在另一个弹出窗口中显示弹出窗口,但不忽略第一个弹出窗口。看起来像这样 我的主要课程如下如何在android的另一个弹出窗口中显示弹出窗口,android,popupwindow,Android,Popupwindow,我想在另一个弹出窗口中显示弹出窗口,但不忽略第一个弹出窗口。看起来像这样 我的主要课程如下 @Override public void onClick(View v) { // TODO Auto-generated method stub location = CommonMethod.locateView(v); showMyPresentationPopup(mContext, location); } private void showMyPresentat
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
location = CommonMethod.locateView(v);
showMyPresentationPopup(mContext, location);
}
private void showMyPresentationPopup(final Context context, Rect loaction) {
int popupWidth = convertDipToPixels(400);
int popupHeight = convertDipToPixels(500);
String statictext;
List<String> mResults = new ArrayList<String>();
for(int i=0;i<15;i++)
{
statictext = "Presentatation "+i+" Name Here";
mResults.add(statictext);
}
PresentationListAdapter mAdapter = new PresentationListAdapter(DashboardActivity.this, mResults);
LayoutInflater layoutInflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
final View layout = layoutInflater.inflate(R.layout.presentation, null);
ListView mListView =(ListView)layout.findViewById(R.id.presentationlistid);
mListView.setAdapter(mAdapter);
mListView.setItemsCanFocus(false);
mListView.setFocusableInTouchMode(false);
displayPopUp(layout,popupWidth, popupHeight,myPresentation,location);
}
// Creating the PopupWindow
public void displayPopUp(View layout,int popupWidth,int popupHeight,View v, Rect location){
mPresentationList = new PopupWindow(mContext);
mPresentationList.setFocusable(true);
mPresentationList.setContentView(layout);
mPresentationList.setWidth(popupWidth);
mPresentationList.setHeight(popupHeight);
mPresentationList.setTouchable(true);
mPresentationList.setBackgroundDrawable(new BitmapDrawable());
mPresentationList.setOutsideTouchable(true);
mPresentationList.setTouchInterceptor(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
mPresentationList.dismiss();
return true;
}
return false;
}
});
mPresentationList.showAsDropDown(v, -convertDipToPixels(20), 0);
}
}
我得到以下错误
android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@4194d750 is not valid; is your activity running?
提前感谢我想你可以隐藏/显示第二个弹出窗口,而不是将其用作弹出窗口,你可以在第一个弹出窗口布局中添加第二个弹出窗口,但在需要之前将其隐藏 如果你不把它当作一个窗口怎么办。让它成为行本身的隐藏元素。显示/隐藏它,由于简单的子顺序,它将在它前面的行上分层。这使您能够完全控制其外观,并使您能够避免受到奇特的弹出式攻击。请查看附件中的图像。我们希望在每行的列表项上打开弹出式窗口,然后在Activity.class的onItemClickListener中添加弹出式代码。我认为你无法从ListAdapter中获得适当的上下文来显示pop。classI会质疑此功能的可用性。如何排除第二次弹出窗口?大多数Android屏幕上可用的UI都很有限,你确定要在工具提示中吃掉更多可见的画面吗?由于空间有限,添加另一个UI元素来掩盖可能有用的内容(或另一个接受手指输入的活动区域)不仅会使内容难以阅读,而且会增加用户意外击中另一个活动区域的风险(比如说,图像上方和右侧的关闭按钮等附近的按钮…)第二个弹出窗口是否会出现
上下文菜单
不起作用?基本上,每行都有一个删除图像。单击删除图像后,第二个弹出窗口将显示为警告弹出窗口,询问“您确定要删除此项目吗?”单击“是”按钮,项目将被删除。这是客户要求。您找到解决方案了吗?我也在这里做类似的事情
android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@4194d750 is not valid; is your activity running?