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);
感謝幫助