- 浏览: 208730 次
- 性别:
- 来自: 大连
-
文章分类
- 全部博客 (54)
- java (17)
- hibernate (3)
- javascript (6)
- Ajax (1)
- 插件 (2)
- 数据库 (3)
- html+css+div (5)
- 其他程序 (3)
- 应用技术 (18)
- office (0)
- 小工具 (1)
- 加密解密 (3)
- mac (3)
- 翻译 (1)
- iphone objectc (5)
- iphone (4)
- android (12)
- 圆角 (1)
- layout (2)
- 加密 (1)
- proguard (2)
- Mac 应用技术 系统 工具 (2)
- Mac 应用技术 系统 工具,xcode4 (1)
- 安卓 (6)
- maven (3)
- 高德 (1)
- 地图 (1)
- lrzsz (1)
- rz (1)
- sz (1)
- 脚本 (1)
- linux (1)
- Android Gradle (1)
- Spark (1)
- mongodb (1)
最新评论
-
Jumper_Wu:
想请教个问题:so文件从maven库中拉到AndroidStu ...
在maven android 工程中使用高德地图 -
cuiqi4016:
可不可以把把html模版作为一个单独的文件引入进来,handl ...
Handlebars 的使用 -
lywangbadan:
Handlebars 的使用 -
lituo20:
不错的,以前接触过一点,看了一下,恍然大悟,好像一下子懂了
Handlebars 的使用 -
zhangyaochun:
其实就是模板化,这是以前就开始推崇的面向数据编程的一个方式。比 ...
Handlebars 的使用
public class ActionSheet implements OnClickListener {
private Context context;
private LinearLayout layout;
private View actionsheetView;
private TextView title;
private Button deleteButton, cancelButton;
private ActionSheetButtonClickListener aslistener;
/**
* This creates a ActionSheet
* @param context
* @param layout
*/
public ActionSheet(Context context, LinearLayout layout) {
this.context = context;
this.layout = layout;
init();
}
private void init() {
LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.actionsheetView = inflater.inflate(R.layout.action_sheet, null);
this.deleteButton = (Button) this.actionsheetView.findViewById(R.id.action_sheet_delete);
this.cancelButton = (Button) this.actionsheetView.findViewById(R.id.action_sheet_cancel);
this.title = (TextView) this.actionsheetView.findViewById(R.id.action_sheet_title);
}
/**
* This
* @param listener
*/
public void setOnButtonClickListener(ActionSheetButtonClickListener listener) {
this.aslistener = listener;
}
/**
* This action sheet
* @param title
*/
public void show(String title) {
this.title.setText(title);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
PixelFormat.TRANSLUCENT);
this.deleteButton.setOnClickListener(this);
this.cancelButton.setOnClickListener(this);
this.actionsheetView.setSoundEffectsEnabled(false);
this.actionsheetView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hide();
}
});
this.layout.addView(this.actionsheetView, lp);
Animation animIn = AnimationUtils.loadAnimation(this.context, R.anim.push_up_in);
animIn.setDuration(200);
animIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Activity parent = (Activity) ActionSheet.this.context;
// using the activity, get Window reference
// Window window = parent.getWindow();
parent.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
parent.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
TransitionDrawable transition = (TransitionDrawable) ActionSheet.this.actionsheetView.getBackground();
transition.startTransition(100);
}
});
this.actionsheetView.setAnimation(animIn);
this.layout.bringChildToFront(this.actionsheetView);
}
/**
* This hide action sheet
*/
public void hide() {
Animation animOut = AnimationUtils.loadAnimation(this.context, R.anim.push_down_out);
animOut.setDuration(200);
animOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
TransitionDrawable transition = (TransitionDrawable) ActionSheet.this.actionsheetView.getBackground();
transition.resetTransition();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
ActionSheet.this.layout.removeView(ActionSheet.this.actionsheetView);
}
});
this.actionsheetView.setAnimation(animOut);
this.actionsheetView.startAnimation(animOut);
}
/**
* {@inheritDoc}
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
@Override
public void onClick(View v) {
if (v.getId() == R.id.action_sheet_delete) {
this.aslistener.onButtonClick(this, 0);
} else {
this.aslistener.onButtonClick(this, 1);
}
}
}
public interface ActionSheetButtonClickListener {
/**
* This actionsheet button call back
* @param index
*/
public void onButtonClick(ActionSheet actionsheet, int index);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/action_sheet_background"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/action_sheet_bg"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/action_sheet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:textColor="@color/white"
android:textSize="20dp" />
<Button
android:id="@+id/action_sheet_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@drawable/action_sheet_delete_button"
android:text="@string/fav_action_sheet_delete"
android:textColor="@color/black"
android:textSize="20dp" />
<Button
android:id="@+id/action_sheet_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/action_sheet_cancel_button"
android:text="@string/cancel"
android:textColor="@color/white"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
action_sheet_bg
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
<item android:drawable="@android:color/transparent"/>
<item android:drawable="@color/action_sheet_background"/>
</transition>
action_sheet_cancel_button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/action_sheet_delete_clicked" android:state_pressed="true"/> <!-- pressed -->
<item android:drawable="@drawable/action_sheet_delete_clicked" android:state_focused="true"/> <!-- focused -->
<item android:drawable="@drawable/action_sheet_delete"/> <!-- default -->
</selector>
action_sheet_delete_button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/action_sheet_cancel_clicked" android:state_pressed="true"/> <!-- pressed -->
<item android:drawable="@drawable/action_sheet_cancel_clicked" android:state_focused="true"/> <!-- focused -->
<item android:drawable="@drawable/action_sheet_cancel"/> <!-- default -->
</selector>
private Context context;
private LinearLayout layout;
private View actionsheetView;
private TextView title;
private Button deleteButton, cancelButton;
private ActionSheetButtonClickListener aslistener;
/**
* This creates a ActionSheet
* @param context
* @param layout
*/
public ActionSheet(Context context, LinearLayout layout) {
this.context = context;
this.layout = layout;
init();
}
private void init() {
LayoutInflater inflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
this.actionsheetView = inflater.inflate(R.layout.action_sheet, null);
this.deleteButton = (Button) this.actionsheetView.findViewById(R.id.action_sheet_delete);
this.cancelButton = (Button) this.actionsheetView.findViewById(R.id.action_sheet_cancel);
this.title = (TextView) this.actionsheetView.findViewById(R.id.action_sheet_title);
}
/**
* This
* @param listener
*/
public void setOnButtonClickListener(ActionSheetButtonClickListener listener) {
this.aslistener = listener;
}
/**
* This action sheet
* @param title
*/
public void show(String title) {
this.title.setText(title);
WindowManager.LayoutParams lp = new WindowManager.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT,
WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_FULLSCREEN | WindowManager.LayoutParams.FLAG_BLUR_BEHIND,
PixelFormat.TRANSLUCENT);
this.deleteButton.setOnClickListener(this);
this.cancelButton.setOnClickListener(this);
this.actionsheetView.setSoundEffectsEnabled(false);
this.actionsheetView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
hide();
}
});
this.layout.addView(this.actionsheetView, lp);
Animation animIn = AnimationUtils.loadAnimation(this.context, R.anim.push_up_in);
animIn.setDuration(200);
animIn.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
Activity parent = (Activity) ActionSheet.this.context;
// using the activity, get Window reference
// Window window = parent.getWindow();
parent.getWindow().addFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
parent.getWindow().setFlags(WindowManager.LayoutParams.FLAG_BLUR_BEHIND, WindowManager.LayoutParams.FLAG_BLUR_BEHIND);
TransitionDrawable transition = (TransitionDrawable) ActionSheet.this.actionsheetView.getBackground();
transition.startTransition(100);
}
});
this.actionsheetView.setAnimation(animIn);
this.layout.bringChildToFront(this.actionsheetView);
}
/**
* This hide action sheet
*/
public void hide() {
Animation animOut = AnimationUtils.loadAnimation(this.context, R.anim.push_down_out);
animOut.setDuration(200);
animOut.setAnimationListener(new AnimationListener() {
@Override
public void onAnimationStart(Animation animation) {
TransitionDrawable transition = (TransitionDrawable) ActionSheet.this.actionsheetView.getBackground();
transition.resetTransition();
}
@Override
public void onAnimationRepeat(Animation animation) {
}
@Override
public void onAnimationEnd(Animation animation) {
ActionSheet.this.layout.removeView(ActionSheet.this.actionsheetView);
}
});
this.actionsheetView.setAnimation(animOut);
this.actionsheetView.startAnimation(animOut);
}
/**
* {@inheritDoc}
* @see android.view.View.OnClickListener#onClick(android.view.View)
*/
@Override
public void onClick(View v) {
if (v.getId() == R.id.action_sheet_delete) {
this.aslistener.onButtonClick(this, 0);
} else {
this.aslistener.onButtonClick(this, 1);
}
}
}
public interface ActionSheetButtonClickListener {
/**
* This actionsheet button call back
* @param index
*/
public void onButtonClick(ActionSheet actionsheet, int index);
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/action_sheet_background"
android:gravity="bottom"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/action_sheet_bg"
android:gravity="center_horizontal"
android:orientation="vertical" >
<TextView
android:id="@+id/action_sheet_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="25dp"
android:textColor="@color/white"
android:textSize="20dp" />
<Button
android:id="@+id/action_sheet_delete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:background="@drawable/action_sheet_delete_button"
android:text="@string/fav_action_sheet_delete"
android:textColor="@color/black"
android:textSize="20dp" />
<Button
android:id="@+id/action_sheet_cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="15dp"
android:background="@drawable/action_sheet_cancel_button"
android:text="@string/cancel"
android:textColor="@color/white"
android:textSize="20dp" />
</LinearLayout>
</LinearLayout>
action_sheet_bg
<?xml version="1.0" encoding="utf-8"?>
<transition xmlns:android="http://schemas.android.com/apk/res/android" >
<!-- The drawables used here can be solid colors, gradients, shapes, images, etc. -->
<item android:drawable="@android:color/transparent"/>
<item android:drawable="@color/action_sheet_background"/>
</transition>
action_sheet_cancel_button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/action_sheet_delete_clicked" android:state_pressed="true"/> <!-- pressed -->
<item android:drawable="@drawable/action_sheet_delete_clicked" android:state_focused="true"/> <!-- focused -->
<item android:drawable="@drawable/action_sheet_delete"/> <!-- default -->
</selector>
action_sheet_delete_button
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/action_sheet_cancel_clicked" android:state_pressed="true"/> <!-- pressed -->
<item android:drawable="@drawable/action_sheet_cancel_clicked" android:state_focused="true"/> <!-- focused -->
<item android:drawable="@drawable/action_sheet_cancel"/> <!-- default -->
</selector>
发表评论
-
Spark 连接 MongoDB
2018-03-07 09:55 3363Spark 连接 Mongodb 官方地址:https://w ... -
解决android4.0系统中菜单(Menu)添加Icon无效问题
2016-02-16 16:23 1022android actionbar menu 显示icon默认 ... -
mac 系统安装rz sz
2015-06-30 11:36 121751.先安装item2,item2 市类似mac风格的终端 ... -
ListView 中嵌套GridView listview item 不能点击问题
2015-03-12 23:28 2134在ListView的item中有GridView,抢占焦点的情 ... -
android 手机传感器
2014-02-18 14:31 1511List<Sensor> sensors = th ... -
android regex utils
2013-12-31 22:43 0public class RegexUtils { pub ... -
Proguard on MacOSX
2013-10-26 23:33 1245[proguard] Error: Can't read [/ ... -
android 自定义progressbar style
2013-09-05 11:22 2743<layer-list xmlns:android=&q ... -
android ADT 17 can not find aapt when build with maven
2013-05-20 23:37 2292更新android adt 版本17之后,程序不能build了 ... -
在maven android 工程中使用高德地图
2013-04-11 21:35 4557由于程序中使用地图,最终选择了高德地图。但是高德地图中需要使用 ... -
android 代码proguard
2013-03-17 13:22 3225大家都知道,java 代码很容易被反编译,同样android ... -
Struts 标签实现时间下来选择
2012-09-13 11:58 1393<select id="min" ... -
MapMarkerExample
2012-04-21 01:21 1349This example show you how to dr ... -
Web browser hacks, Css hacks - ie, firefox, chrome, safri, Opera
2013-04-11 21:35 1162CSS hacks take advantage of bro ... -
Xcode 4 更改下载组件的appleId
2012-04-13 16:40 2517You can change the Apple Develo ... -
Handlebars 的使用
2012-03-31 01:12 33736web 开发中,js 解析JSON 是经常的事情。非常繁琐。h ... -
使用CSS实现间隔线|(竖线)
2012-04-13 16:40 2230是不是考虑用这个? <a href="#&qu ... -
[WARN]Warning: Multiple build commands for output file /
2011-12-13 11:48 9999xcode中 有时候会报一个警告: [WARN]Warning ... -
xcode missing file xxxx
2011-12-13 11:44 4910搞过iphone开发的应该都知道,如果你在finder中删除了 ... -
android 程序 发布加密
2011-12-01 13:37 3288大家都知道,现在java程序很容易就让别人反编译,andori ...
相关推荐
`ios-PQActionSheet-仿微信的ActionSheet.zip`这个压缩包文件包含了一个名为`PQActionSheet`的第三方库,它的目标是模仿微信ActionSheet的功能和外观,为开发者提供一种更加便捷的使用方式。 `PQActionSheet`主要...
在iOS的设计规范中,ActionSheet通常用于iPad应用程序,而在iPhone上,当屏幕空间有限时,它会以模态对话框的形式出现。在Android平台,ActionSheet的概念也得到了实现,尽管在具体表现形式上可能略有不同,但基本...
在Android开发中,为了提供与iOS相似的用户体验,开发者经常需要实现类似iPhone的UI组件。在iOS中,UIActionSheet是一种常见的控件,用于展示一系列可供用户选择的选项,通常在底部弹出。而在Android中,我们可以...
1. **仿微信样式**:`LemonActionSheet`在视觉效果上与微信的`ActionSheet`保持一致,包括字体、颜色、布局以及动画效果,为用户提供熟悉的交互体验。 2. **快速移植**:开发者可以轻松地将`LemonActionSheet`引入...
在iOS应用开发中,ActionSheet通常用于向用户展示一组可选操作,比如在邮件应用中选择"保存"、"删除"或"取消"等。微博和微信作为中国最流行的社交应用,它们的交互设计和用户体验往往成为其他开发者模仿的对象。这款...
在这个"多样式的选择器(iPhone源代码)"中,作者创建了一个名为`MHActionSheet`的自定义组件,它扩展了`UIActionSheet`的功能。`MHActionSheet`仿照了微信ActionSheet的设计,这可能意味着它具有类似的颜色、字体、...
如果希望在iPad上获得类似iPhone的全屏效果,可以设置`modalPresentationStyle`为`.fullScreen`。 7. **响应链**: 考虑到响应链的正确性,确保弹出视图的呈现不会被其他未处理的用户交互打断。确保在适当的地方...