Skip to content Skip to sidebar Skip to footer

Add Layout Programmatically Inside Another One

I have an xml file (option_element.xml) that contains a ImageView and a TextView Copy

to:

LinearLayoutoptions_layout= (LinearLayout) findViewById(R.id.options_list);
String[] options = getActivity().getResources().getStringArray(R.array.options);
for (inti=0; i < options.length; i++) {
    Viewto_add= inflater.inflate(R.layout.options_element,
                options_layout,false);

    TextViewtext= (TextView) to_add.findViewById(R.id.text);
    text.setText(options[i]);
    text.setTypeface(FontSelector.getBold(getActivity()));
    options_layout.addView(to_add);
}

Post a Comment for "Add Layout Programmatically Inside Another One"