Search in sources :

Example 1 with YieldLayout

use of me.tatarka.yieldlayout.YieldLayout in project yield-layout by evant.

the class DynamicExampleFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    RadioGroup btnLayoutGroup = (RadioGroup) view.findViewById(R.id.btn_layout_group);
    final YieldLayout yieldLayout = (YieldLayout) view.findViewById(R.id.yield_layout);
    btnLayoutGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {

        @Override
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            int layout = checkedId == R.id.btn_layout_1 ? R.layout.dynamic_layout_1 : R.layout.dynamic_layout_2;
            yieldLayout.setLayoutResource(layout);
        }
    });
    // listener doesn't get called if on the default option
    if (btnLayoutGroup.getCheckedRadioButtonId() == R.id.btn_layout_1) {
        yieldLayout.setLayoutResource(R.layout.dynamic_layout_1);
    }
}
Also used : RadioGroup(android.widget.RadioGroup) YieldLayout(me.tatarka.yieldlayout.YieldLayout)

Aggregations

RadioGroup (android.widget.RadioGroup)1 YieldLayout (me.tatarka.yieldlayout.YieldLayout)1