-
仿IOS 对话框
package com.zf.iosdialog.widget;import android.app.Dialog;import android.content.Context;import android.view.Display;import android.view.LayoutInflater;import android.view.View;import android.view.View.OnClickListener;import android.view.WindowManager;import android.widget.Button;import android.widget.FrameLayout;import android.widget.ImageView;import android.widget.LinearLayout;import android.widget.LinearLayout.LayoutParams;import android.widget.TextView;import com.zf.iosdialog.R;public class AlertDialog {private Context context;private Dialog dialog;private LinearLayout lLayout_bg;private TextView txt_title;private TextView txt_msg;private Button btn_neg;private Button btn_pos;private ImageView img_line;private Display display;private boolean showTitle = false;private boolean showMsg = false;private boolean showPosBtn = false;private boolean showNegBtn = false;public AlertDialog(Context context) {this.context = context;WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);display = windowManager.getDefaultDisplay();}public AlertDialog builder() {// 获取Dialog布局View view = LayoutInflater.from(context).inflate(R.layout.view_alertdialog, null);// 获取自定义Dialog布局中的控件lLayout_bg = (LinearLayout) view.findViewById(R.id.lLayout_bg);txt_title = (TextView) view.findViewById(R.id.txt_title);txt_title.setVisibility(View.GONE);txt_msg = (TextView) view.findViewById(R.id.txt_msg);txt_msg.setVisibility(View.GONE);btn_neg = (Button) view.findViewById(R.id.btn_neg);btn_neg.setVisibility(View.GONE);btn_pos = (Button) view.findViewById(R.id.btn_pos);btn_pos.setVisibility(View.GONE);img_line = (ImageView) view.findViewById(R.id.img_line);img_line.setVisibility(View.GONE);// 定义Dialog布局和参数dialog = new Dialog(context, R.style.AlertDialogStyle);dialog.setContentView(view);// 调整dialog背景大小lLayout_bg.setLayoutParams(new FrameLayout.LayoutParams((int) (display.getWidth() * 0.85), LayoutParams.WRAP_CONTENT));return this;}public AlertDialog setTitle(String title) {showTitle = true;if ("".equals(title)) {txt_title.setText("标题");} else {txt_title.setText(title);}return this;}public AlertDialog setMsg(String msg) {showMsg = true;if ("".equals(msg)) {txt_msg.setText("内容");} else {txt_msg.setText(msg);}return this;}public AlertDialog setCancelable(boolean cancel) {dialog.setCancelable(cancel);return this;}public AlertDialog setPositiveButton(String text,final OnClickListener listener) {showPosBtn = true;if ("".equals(text)) {btn_pos.setText("确定");} else {btn_pos.setText(text);}btn_pos.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {listener.onClick(v);dialog.dismiss();}});return this;}public AlertDialog setNegativeButton(String text,final OnClickListener listener) {showNegBtn = true;if ("".equals(text)) {btn_neg.setText("取消");} else {btn_neg.setText(text);}btn_neg.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {listener.onClick(v);dialog.dismiss();}});return this;}private void setLayout() {if (!showTitle && !showMsg) {txt_title.setText("提示");txt_title.setVisibility(View.VISIBLE);}if (showTitle) {txt_title.setVisibility(View.VISIBLE);}if (showMsg) {txt_msg.setVisibility(View.VISIBLE);}if (!showPosBtn && !showNegBtn) {btn_pos.setText("确定");btn_pos.setVisibility(View.VISIBLE);btn_pos.setBackgroundResource(R.drawable.alertdialog_single_selector);btn_pos.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {dialog.dismiss();}});}if (showPosBtn && showNegBtn) {btn_pos.setVisibility(View.VISIBLE);btn_pos.setBackgroundResource(R.drawable.alertdialog_right_selector);btn_neg.setVisibility(View.VISIBLE);btn_neg.setBackgroundResource(R.drawable.alertdialog_left_selector);img_line.setVisibility(View.VISIBLE);}if (showPosBtn && !showNegBtn) {btn_pos.setVisibility(View.VISIBLE);btn_pos.setBackgroundResource(R.drawable.alertdialog_single_selector);}if (!showPosBtn && showNegBtn) {btn_neg.setVisibility(View.VISIBLE);btn_neg.setBackgroundResource(R.drawable.alertdialog_single_selector);}}public void show() {setLayout();dialog.show();}}
- 2015-01-03下载
- 积分:1
-
选项卡栏 Android 项目
关于使用选项卡栏 control.u 的 android 应用程序创建选项卡可以添加任何 android application.creating 选项卡上使用选项卡栏 control.u 的 android 应用程序中的新选项卡可以在任何 android 的应用程序中添加新的选项卡。创建选项卡上使用选项卡栏 control.u 的 android 应用程序可以在任何 android 的应用程序中添加新选项卡。
- 2023-04-14 21:25:03下载
- 积分:1
-
电子阅读
实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读实现电子书阅读
- 2022-07-03 16:35:01下载
- 积分:1
-
android listview 异步加载网络图片示例源码下载(亲测通过,不卡)
listview 异步加载网络图片,支持拖动下一页,不卡
- 2014-04-13下载
- 积分:1
-
安卓程序源代码,软件管理器源代码
这是自己写的软件管理器的源代码,作用是读出手机现有的软件,并且可以区分是系统软件还是第三方的软件
- 2022-04-15 09:15:42下载
- 积分:1
-
Android 天气预报毕业设计论文含项目源码
Android 天气预报毕业设计论文含项目源码,由天津职业技术师范大学本科生魏杰设计创作,这个天气预报Android源代码为用户提供一个方便快捷的天气信息查看方式,用户只需要简单的点击操作,就可以查看当天天气,软件可以列举遍及全国34个盛直辖市和自治区,精确到县(区)的天气情况,并搭配与天气相对的背景图片与小图标,给用户以直接美观的软件体验。
经过一段时间的努力,终于完成了目前水平的手机天气预报软件,这是我第一次完整的从头到尾完成的一个Android项目,虽然功能简单,界面也没有过多的修饰,但是对我之前学习Android也算是做了个总结,将之前学过的大多数功能都运用进了这个App
关键词:Android;天气预报;JAVA;JSON。
- 2022-08-18 23:48:08下载
- 积分:1
-
android 对话框实例
android 对话框实例
- 2014-08-21下载
- 积分:1
-
Android-memory-manage-
非常好,非常棒,非常不错的android内存管理。(android memory manage)
- 2013-10-09 07:41:43下载
- 积分:1
-
安卓蓝牙4.0自动扫描连接
本资源是关于安卓系统与蓝牙4.0,2.0互连通信的例程。可实现的功能包括扫描,自动连接,数据通信等。4.0采用android bluetooth Le API。程序亲测可用。
- 2022-08-08 10:57:46下载
- 积分:1
-
QR_CodeScan
将蓝牙地址做成二维码,手机扫码直接蓝牙连接。(Make Bluetooth address into two-dimensional code, scan code and connect directly with Bluetooth.)
- 2020-06-21 17:40:01下载
- 积分:1