Published
- 1 min read
Dynamic UI Layout Rendering Android

Feature
- Dynamically load text-input, text-drop-down,text-field from business data
Blocker
- Inability to set custom ids to set the required text and hints for the ui components.
Solution
- Since the layout is defined the child elements can be retrieved using the
- layout.getChildAt(index) — this will return the ui component at the given index
- getResources().getIdentifier(<id>,<resourceType>,<activity.getPackageName()>) — this will return the ui component that is using the id that was defined earlier
Sample Code
LinearLayout linearLayout = (LinearLayout) inflater.inflate(view, null, false);
TextView labelTextView = (TextView) linearLayout.getChildAt(<index>);labelTextView.setId(<id>);
TextView specialNotesTextInputLabel = (TextView)rootView.findViewById(getResources().getIdentifier(<id>,<resource-type>,<activity>);
specialNotesTextInputLabel.setText(<text>);