MenuDrawer

网址如下:

https://github.com/SimonVT/android-menudrawe

在导入Eclipse的时候,如果出现错误,一般修改一下android版本号就行了。

该项目提供了诸多滑动菜单的实现:

MenuDrawerMenuDrawer

该项目的基本使用方法如下:

1. 将该项目中的menudrawer作为库导入到需要使用的项目中;

2. 

package com.sun.uidemo;

import net.simonvt.menudrawer.MenuDrawer;
import net.simonvt.menudrawer.Position;
import android.app.Activity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class SlidingMenuActivity extends Activity {
	private MenuDrawer mMenuDrawer;
	private ListView mMenu;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		LayoutInflater lf = this.getLayoutInflater();
		View view = lf.inflate(R.layout.menu_layout, null);
		mMenu = (ListView) view.findViewById(R.id.m);
		mMenu.setAdapter(new ArrayAdapter<String>(this,
				android.R.layout.simple_list_item_1, new String[] { "item1",
						"item2", "item3", "item4", "item5", "item6", "item7",
						"item8", "item9", "item10", "item11", "item12",
						"item13", "item14" }));

		mMenuDrawer = MenuDrawer.attach(this, MenuDrawer.Type.BEHIND,
				Position.START, MenuDrawer.MENU_DRAG_CONTENT);
		mMenuDrawer.setMenuView(view);
		mMenuDrawer.setContentView(R.layout.content_layout);
		mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
		mMenuDrawer.setSlideDrawable(R.drawable.ic_drawer);
		mMenuDrawer.setDrawerIndicatorEnabled(true);
		mMenu.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> parent, View view,
					int position, long id) {
				mMenuDrawer.toggleMenu();
			}
		});
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			mMenuDrawer.toggleMenu();
			return true;
		}

		return super.onOptionsItemSelected(item);
	}
}



基本的使用方法就是这样,可以根据该项目提供的参考实例实现更丰富的功能。



你可能感兴趣的:(android,UI)