我想在另一个弹出窗口中显示弹出窗口而不关闭第一个弹出窗口。它看起来像这样
我的主要课程如下
@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);
}
我试图打开另一个弹出窗口的我的 getview 方法
@Override
public View getView(int pos, View convertview, final ViewGroup arg2) {
// TODO Auto-generated method stub
final Viewholder holder;
if(convertview==null){
LayoutInflater layoutInflater =(LayoutInflater)context.getSystemService(context.LAYOUT_INFLATER_SERVICE);
convertview=layoutInflater.inflate(R.layout.presentationitem, null,false);
holder=new Viewholder();
holder.Title=(TextView)convertview.findViewById(R.id.presentationtitle);
holder.mRefresh=(Button)convertview.findViewById(R.id.refreshid);
holder.mDelete=(Button)convertview.findViewById(R.id.deleteid);
holder.mDelete.setFocusable(false);
holder.mRefresh.setFocusable(false);
holder.mDelete.setFocusableInTouchMode(false);
holder.mRefresh.setFocusableInTouchMode(false);
convertview.setTag(holder);
}
else{
holder=(Viewholder)convertview.getTag();
}
Log.e("adapter5453===>",wifilist.get(pos));
holder.Title.setText(wifilist.get(pos));
holder.mRefresh.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
int popupWidth = 250;
int popupHeight = 100;
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = layoutInflater.inflate(R.layout.sync_dialog, null);
displayRefreshPopUp(layout,popupWidth, popupHeight,v,location);
}
});
convertview.setTag(R.string.close, wifilist.get(pos));
return convertview;
}
static class Viewholder{
TextView Title;
Button mRefresh;
Button mDelete;
}
public void displayRefreshPopUp(View layout,int popupWidth,int popupHeight,View v, Rect location){
mRefreshPopUp = new PopupWindow(context);
mRefreshPopUp.setContentView(layout);
mRefreshPopUp.setWidth(popupWidth);
mRefreshPopUp.setHeight(popupHeight);
mRefreshPopUp.setTouchable(true);
mRefreshPopUp.setFocusable(true);
mRefreshPopUp.setBackgroundDrawable(new BitmapDrawable());
mRefreshPopUp.setOutsideTouchable(true);
mRefreshPopUp.setTouchInterceptor(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
mRefreshPopUp.dismiss();
return true;
}
return false;
}
});
mRefreshPopUp.showAsDropDown(v, -20, 0);
//mRefreshPopUp.showAtLocation(v, Gravity.TOP, 0, 0);
} }
我收到以下错误。
android.view.WindowManager$BadTokenException: Unable to add window -- token android.view.ViewRootImpl$W@4194d750 is not valid; is your activity running?
提前致谢