Giter Site home page Giter Site logo

actionsheet's Introduction

ActionSheet

参照ios中的 actionsheet样式做的Android ui界面。详解参见博客仿IOS控件之ActionSheet

效果图

包含两种界面,四种样式:

  1. 顶部下拉layout菜单 和 底部弹出式ActionSheet菜单

Screenshot    Screenshot

  1. 后来,在此基础上,整合了baoyz的AcitonSheet,添加了带title通用性更强但是耦合性稍差的新样式菜单

有两种样式,分别为IOS6和IOS7风格

Screenshot    Screenshot

如何使用

项目本身体积不大,可以引用库或者直接拷贝至自己的项目中去,使用方法很简单

1. 第一种顶部弹出菜单ActionSheetLayout。

ActionSheetLayout就当做普通的linearlayout来使用,然后调用
布局中xml

<com.qiao.actionsheet.view.ActionSheetLayout
            android:id="@+id/action_sheet_layout"
            android:layout_width="match_parent"
            android:layout_height="match_parent" >
            <!-- 当做linearlayout使用-->
</com.qiao.actionsheet.view.ActionSheetLayout>

java代码

	actionSheetLayout = (ActionSheetLayout) findViewById(R.id.action_sheet_layout);

	//直接调用hide()和()来控制显示隐藏
	if(actionSheetLayout.isShow()){
		actionSheetLayout.hide();
	}else{
		actionSheetLayout.show();
	}

2. 底部弹出菜单ActionSheet

使用很简单:

	final ActionSheet actionSheet = new ActionSheet(MainActivity.this);
	actionSheet.show("确定要退出么?",new String[]{"退出" },new Action1<Integer>(){
		@Override
		public void invoke(Integer index) {
			actionSheet.hide();
			if(index==0){
				MainActivity.this.finish();
			}
		}
	});

3. 使用baoyz兄的Actionsheet整改后的

具体使用见代码demo

		baoyz.qiao.actionsheet.ActionSheet.init(this)
				.setTitle("This is test title ,do you want do something?")
				.setTheme(resid)
				.setItemTexts("Item1", "Item2", "Item3", "Item4")
				.setItemClickListener(new ItemClikListener() {
					@Override
					public void onitemClick(
							baoyz.qiao.actionsheet.ActionSheet actionSheet,
							int index) {
						Toast.makeText(getApplicationContext(), "click item index = " + index,0).show();
					}
				})
				.setCancelText("Cancel")
//				.setCancelText("Cancel",new CancelListener() {
//					@Override
//					public void onCancelClick(ActionSheet actionSheet) {
//						Toast.makeText(getApplicationContext(), "dismissed ", 0).show();
//					}
//				})
				.show();

其中,

  • setTheme() 参数可选 R.style.ActionSheetStyleIOS6 或 R.style.ActionSheetStyleIOS6 。不设置则默认为 R.style.ActionSheetStyleIOS7。注:
  • 不设置 setTitle 则为无title样式
  • setCanTouchOutside(false) 点击选项外无响应,默认为true,点击隐藏
  • 不设置 setCancelText() 则不显示取消按钮。其参数有两个,第一个string为显示内容,第二个listener为对应事件
  • 最后,别忘记 show() 让其显示。

actionsheet's People

Contributors

qiaoidea avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.