Android Open Source - android_module_slide Menu Activity






From Project

Back to project page android_module_slide.

License

The source code is released under:

Apache License

If you think the Android project android_module_slide 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

/*
 * #%L/*from w  w w  .j  a  v  a2 s  .c  o  m*/
 * SlidingMenuDemo
 * $Id:$
 * $HeadURL:$
 * %%
 * Copyright (C) 2012 Paul Grime
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * #L%
 */
package com.mi.core.slidingmenu;

import com.mi.core.slidingmenu.R;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

/**
 * Simple Activity that uses each Button in the layout to invoke an Activity.
 */
public class MenuActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final String packageName = this.getClass().getPackage().getName();
        final Context context = this;

        // ScrollView
        ViewGroup contentView = (ViewGroup) LayoutInflater.from(context).inflate(R.layout.activity_menu, null);

        // Layout containing Buttons
        ViewGroup g = (ViewGroup) contentView.getChildAt(0);
        int count = g.getChildCount();

        for (int i = 0; i < count; i++) {
            Button btn = (Button) g.getChildAt(i);
            final String text = btn.getText().toString();
            btn.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View v) {
                    try {
                        Class c = Class.forName(packageName + "." + text);
                        startActivity(new Intent(context, c));
                    } catch (ClassNotFoundException e) {
                        Toast.makeText(context, String.valueOf(e), 5000).show();
                    }
                }
            });
        }

        setContentView(contentView);
    }
}




Java Source Code List

com.mi.core.slidingmenu.AnimationStackedFrames.java
com.mi.core.slidingmenu.HorzScrollWithImageMenu.java
com.mi.core.slidingmenu.HorzScrollWithListMenu.java
com.mi.core.slidingmenu.MenuActivity.java
com.mi.core.slidingmenu.MyHorizontalScrollView.java
com.mi.core.slidingmenu.PushLeftPushRightAnimation.java
com.mi.core.slidingmenu.SlideAnimationThenCallLayout.java
com.mi.core.slidingmenu.TestSlideActivity.java
com.mi.core.slidingmenu.ViewUtils.java