Android Open Source - yield-layout Dynamic Example Fragment






From Project

Back to project page yield-layout.

License

The source code is released under:

Apache License

If you think the Android project yield-layout listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package me.tatarka.yieldlayout.sample;
/*w w w .ja va2 s .c o  m*/
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RadioGroup;

import me.tatarka.yieldlayout.YieldLayout;

public class DynamicExampleFragment extends ExampleFragment {
    @Override
    public String getTitle() {
        return "Dynamic Example";
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return inflater.inflate(R.layout.use_dynamic_yield, container, false);
    }

    @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);
        }
    }
}




Java Source Code List

me.tatarka.yieldlayout.YieldLayoutInflater.java
me.tatarka.yieldlayout.YieldLayout.java
me.tatarka.yieldlayout.Yield.java
me.tatarka.yieldlayout.sample.BasicExampleFragment.java
me.tatarka.yieldlayout.sample.DynamicExampleFragment.java
me.tatarka.yieldlayout.sample.ExampleFragment.java
me.tatarka.yieldlayout.sample.ListExampleFragment.java
me.tatarka.yieldlayout.sample.MyActivity.java