Android create reusable layout

自作多情 提交于 2019-12-12 06:46:21

问题


How to create a single pop up layout with textbox that can be called anywhere on the app. See below pseudo codes of what I mean;

PopUpClass popup;
private static Singleton instance = null;
class Singleton {
   if(instance == null) {
      instance = new Singleton ();
      // Instantiate a class pop up class layout
       popup = new PopUpClass(); // I dont know how to create this one
    }
    return instance;
}


SomeClass {
   private buttonClicked {
   Singleton singleton = new Singleton();
   PopUpClass popup = singleton.popup;

   //add the pop up class to current view
   }
}

This means that I want the pop up class created only once so that whatever text on the layout that done on someclass it can also be show on other class.


回答1:


If you want to show same textbox or other widgets in every layout, then better way is to create a layout and include this layout in every activity you want to show this.. Can refer this linklink



来源:https://stackoverflow.com/questions/14271691/android-create-reusable-layout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!