Android Open Source - fragment-navigation Third Fragment






From Project

Back to project page fragment-navigation.

License

The source code is released under:

Apache License

If you think the Android project fragment-navigation 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 be.hcpl.android.fragment.navigation.fragments;
/*from  www . ja v a  2s . c  o  m*/
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import be.hcpl.android.fragment.navigation.MainActivity;
import be.hcpl.android.fragment.navigation.R;

/**
 * An example fragment that can be loaded in place
 */
public class ThirdFragment extends TemplateFragment {

    public static ThirdFragment createInstance() {
        return new ThirdFragment();
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // this is how we load a specific layout
        return inflater.inflate(R.layout.first_fragment, container, false);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        // and here our view is loaded

        ((TextView) view.findViewById(R.id.txtOnTop)).setText(new StringBuilder("You're now on ").append(this.getClass().getSimpleName()).toString());

        view.findViewById(R.id.btnFirstFragment).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity) getActivity()).switchContent(FirstFragment.createInstance());
            }
        });
        view.findViewById(R.id.btnSecondFragment).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                ((MainActivity) getActivity()).switchContent(SecondFragment.createInstance());
            }
        });
        view.findViewById(R.id.btnThirdFragment).setEnabled(false);
    }
}




Java Source Code List

be.hcpl.android.fragment.navigation.MainActivity.java
be.hcpl.android.fragment.navigation.fragments.AboutFragment.java
be.hcpl.android.fragment.navigation.fragments.FirstFragment.java
be.hcpl.android.fragment.navigation.fragments.NavigationDrawerFragment.java
be.hcpl.android.fragment.navigation.fragments.SecondFragment.java
be.hcpl.android.fragment.navigation.fragments.TemplateFragment.java
be.hcpl.android.fragment.navigation.fragments.ThirdFragment.java