Creating a professional in app user interface in Android -


Text after "

Current state:

We have different userinterfaces, which, for example, form the menuFragment pieces Are:

  Public Square MenuFragment extends the spread piece, hideable, View.OnClickListener {@Override Public View onCreateView (LayoutInflater inflater, ViewGroup container, bundled savedInstanceState) {this.view = inflater Inflate (R.layout menu, container, wrong); } @ Override Public Zero Hide () {view.setVisibility (see GONE); } @ Override Public Wide Show () {view.setVisibility (see Visual); }}  

Hideable:

  Public stable interface Hideable {Zero Hide (); Zero show (); }  

The state is:

  public anonym interfaceset {standard, two, three; Private listing & lt; Hideable & gt; VisibleElements; Private Zero SetVisible Elements (Hide [] visible elements) {this.visibleElements = Arrays.asList (visible elements); }}  

Set up using:

  InterstateState.Standard.segetable elements (hide new [] {menuFragment});  

Where there is menuFragment

  menuFragment = (MenuFragment) activity.getFragmentManager () findFragmentById (R.id.menu_fragment).  

Now I call the state to change changeToState:

  public zero changeToState (InterfaceState state) {from the list & lt; Hideable & gt; HideList = New Linkedist & lt; & Gt; (); (Hidden E: this currentState.visibleElements) {if (! State Visual Elements Consent (e)) hideList.add (e); E.hide (); } List & lt; Hideable & gt; Show list = new linked list & lt; & Gt; (); (Hideable E: state. Visible) {if (! This.currentState.visibleElements.contains (e)) showList.add (e); E.show (); }  

The system looks buggy sometimes UI elements are not visible.

Question:

  1. Is this a good way to implement a UI? If not, what is a better way of doing it?
  2. Does Android allocate space for a view, whose visibility = "is gone"? To use the upper mechanism, I need to define all UI elements (like MenuFragment menuFragment) when the app starts directly.
  3. Any suggestions / improvements?

Thanks to all readers << / P>

  1. < P> I always rule the conference on the configuration . Android has some good conferences that allow you to design user interfaces and keep them whenever possible.

  2. No it is not. This is the reason, the View.GONE view works as if it is not there (from the layout point of view), where as view.INVISIBLE for the layout space See the required allocation, but just looks to see the invisible. However, even with View.GONE , you can still see findViewById () .

  3. I think the storage of information in an enum is bad idea, you should get a different method that suits you (either a list Enter the application class or something similar in).

  4. Edit: You can find some useful information about the pattern, and you can read more about Android design guidelines. There is a good document about the pattern as well as you can see AOP (or, good rule), because they provide some good conventions on how to write code.


Comments