Back to project page SlideMenu.
The source code is released under:
Apache License
If you think the Android project SlideMenu listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* * Copyright (C) 2014 fengwx.cn@gmail.com */* w w w . ja v a 2s. com*/ * 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. */ package org.fengwx; import org.fengwx.slidemenu.R; import org.fengwx.slidemenu.SlideMenu; import android.app.Activity; import android.graphics.Color; import android.os.Bundle; import android.view.KeyEvent; import android.view.View; import android.widget.ArrayAdapter; import android.widget.ListView; /** * Test SlideMenu Activity * * @author fengwx */ public class SlideMenuActivity extends Activity { private SlideMenu mSlideMenu; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // set slide view mSlideMenu = new SlideMenu(this); setContentView(mSlideMenu); // fill data String[] items = new String[50]; for (int i = 0; i < 50; i++) { items[i] = "Item " + (i + 1); } // set content view View content = getLayoutInflater().inflate(R.layout.main, null); content.setBackgroundColor(Color.parseColor("#0ff0f0")); ListView contentList = (ListView) content.findViewById(R.id.listview); contentList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items)); mSlideMenu.setContentView(content, new SlideMenu.LayoutParams(SlideMenu.LayoutParams.MATCH_PARENT, SlideMenu.LayoutParams.MATCH_PARENT)); // set left view View left = getLayoutInflater().inflate(R.layout.main, null); left.setBackgroundColor(Color.parseColor("#666666")); ListView leftList = (ListView) left.findViewById(R.id.listview); leftList.setAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, items)); mSlideMenu.setLeftMenuView(left, new SlideMenu.LayoutParams(300, SlideMenu.LayoutParams.MATCH_PARENT)); } @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { mSlideMenu.toggle(); return true; } return super.onKeyDown(keyCode, event); } }