-
仿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 ViewPager 左右双向滑动 实例源码
android ViewPager 左右双向滑动 实例源码
- 2014-08-08下载
- 积分:1
-
菜单三方控件
菜单三方控件
- 2014-10-04下载
- 积分:1
-
Android开源小说阅读器CoolReader源码
Android开源小说阅读器CoolReader源码
- 2015-04-06下载
- 积分:1
-
Android中实现notification 消息通知实例 附源码
android 消息通知功能实例
- 2013-03-08下载
- 积分:1
-
android 播放网络MP3 音乐播放
简单的基本功能,实测可行。 核心代码:package com.sharpandroid.music.activity;import java.io.IOException;import android.app.Activity;import android.os.Bundle;import android.util.Log;import android.view.View;import android.widget.Button;import android.widget.ImageButton;import android.widget.SeekBar;import android.widget.TextView;import com.sharpandroid.music.R;import com.sharpandroid.music.StreamingMediaPlayer;public class MediaPlayer extends Activity { private Button streamButton; private ImageButton playButton; private boolean isPlaying; private TextView playTime; private StreamingMediaPlayer audioStreamer; @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); initControls(); } private void initControls() { playTime=(TextView) findViewById(R.id.playTime); streamButton = (Button) findViewById(R.id.button_stream); streamButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { startStreamingAudio(); }}); playButton = (ImageButton) findViewById(R.id.button_play); playButton.setEnabled(false); playButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { if (audioStreamer.getMediaPlayer().isPlaying()) { audioStreamer.getMediaPlayer().pause(); playButton.setImageResource(R.drawable.button_play); } else { audioStreamer.getMediaPlayer().start(); audioStreamer.startPlayProgressUpdater(); playButton.setImageResource(R.drawable.button_pause); } isPlaying = !isPlaying; }}); } private void startStreamingAudio() { try { final SeekBar progressBar = (SeekBar) findViewById(R.id.progress_bar); if ( audioStreamer != null) { audioStreamer.interrupt(); } audioStreamer = new StreamingMediaPlayer(this, playButton, streamButton, progressBar,playTime); audioStreamer.startStreaming("http://192.168.64.1/xa.mp3",5208, 216); streamButton.setEnabled(false); } catch (IOException e) { Log.e(getClass().getName(), "读取音乐出错!", e); } }}
- 2014-05-26下载
- 积分:1
-
android 加载网页Html文本--WebView
解决了乱码问题
- 2015-04-22下载
- 积分:1
-
android显示全国重要城市的列表(带字母导航),高仿Android 58城市
数据库在本地 asset
- 2015-06-27下载
- 积分:1
-
读取SIM卡联系人相关文件的信息,包含EFS文件相对应的人信息,sim卡联系人存储的容量,sim卡联系人的操作等等
用于调试SIM卡联系人,可以检测sim卡联系人的ADN ,SDN ,FDN 等容量信息,支持读取sim卡联系人到手机,支持高通最新的双卡方案
- 2015-06-16下载
- 积分:1
-
安卓多功能手机助手项目
本项目是一套基于安卓手机的多功能手机助手的项目源码,实现的功能有手机软件的管理、硬件信息的读取显示、电量情况读取和显示、闹钟设置、相机、通讯录、联系人、短信的读取和显示。还可以一键结束程序,看了一下源码注释很丰富,功能模块代码也都是放在独立的包里,总体来说是套不错的源码,值得借鉴学习涉及模块&技术联系人读取通话记录读取短信读取软件管理一键结束程序闹钟硬件信息读取
- 2015-06-15下载
- 积分:1