0
我有一个单独的弹出式窗口,当我在活动中调用它时效果很好。但我的想法是为这个popupWindows设置特定的类并通过不同的活动调用它。这怎么可能 ?如何在2个活动之间共享popwindows
我popupWindows类
public class GestionCat extends PopupWindow
{ 语境m_context;
public GestionCat(Context context)
{
super(context);
m_context = context;
setContentView(LayoutInflater.from(context).
inflate(R.layout.cat, null));
setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
setWidth(WindowManager.LayoutParams.WRAP_CONTENT);
}
public void show(View anchor)
{
showAtLocation(anchor, Gravity.CENTER, 0, 0);
}
}
我怎么称呼它:
Activity activity = this.getParent();
View view = activity.findViewById(R.layout.main_layout);
Context context = getApplicationContext();
GestionCat gestionCat = new GestionCat(context);
gestionCat.show(view);
感谢帮助