Android Open Source - fonticon Menu Fragment






From Project

Back to project page fonticon.

License

The source code is released under:

Apache License

If you think the Android project fonticon 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 com.shamanland.fonticon.example;
//from   w  w  w.j av a 2  s .  co  m
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class MenuFragment extends Fragment implements View.OnClickListener {
    private int mSelectedMenuId;

    @Override
    public void onCreate(Bundle state) {
        super.onCreate(state);

        if (state != null) {
            mSelectedMenuId = state.getInt("selected.menu.id", 0);
        }
    }

    @Override
    public void onSaveInstanceState(Bundle state) {
        super.onSaveInstanceState(state);

        state.putInt("selected.menu.id", mSelectedMenuId);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle state) {
        View root = inflater.inflate(R.layout.f_menu, container, false);

        if (root instanceof ViewGroup) {
            ViewGroup group = (ViewGroup) root;
            int count = group.getChildCount();

            for (int i = 0; i < count; ++i) {
                View view = group.getChildAt(i);
                if (view != null) {
                    view.setOnClickListener(this);
                }
            }

            if (mSelectedMenuId != 0) {
                onClick(root.findViewById(mSelectedMenuId));
            }
        }

        return root;
    }

    @Override
    public void onClick(View v) {
        FragmentActivity activity = getActivity();
        if (activity instanceof MenuListener) {
            String menuText = null;

            if (v instanceof TextView) {
                CharSequence text = ((TextView) v).getText();
                if (text != null) {
                    menuText = text.toString();
                }
            }

            ((MenuListener) activity).onMenuClicked(v.getId(), menuText, mSelectedMenuId != v.getId());
            mSelectedMenuId = v.getId();
        }
    }
}




Java Source Code List

com.shamanland.fonticon.CompoundDrawables.java
com.shamanland.fonticon.FontIconButton.java
com.shamanland.fonticon.FontIconDrawable.java
com.shamanland.fonticon.FontIconEditText.java
com.shamanland.fonticon.FontIconTextView.java
com.shamanland.fonticon.FontIconToggleButton.java
com.shamanland.fonticon.FontIconTypefaceHolder.java
com.shamanland.fonticon.FontIconView.java
com.shamanland.fonticon.TextPaintHelper.java
com.shamanland.fonticon.example.CompoundIconsFragment.java
com.shamanland.fonticon.example.ContentFragment.java
com.shamanland.fonticon.example.GlowingIconsFragment.java
com.shamanland.fonticon.example.MainActivity.java
com.shamanland.fonticon.example.MenuFragment.java
com.shamanland.fonticon.example.MenuListener.java
com.shamanland.fonticon.example.MyApplication.java
com.shamanland.fonticon.example.ScaledIconsFragment.java