上一页 1 2 3 4 5 6 ··· 10 下一页
摘要: /** * double 类型取后面N位小数 N自定义. * @param nodesTemp * @return */ public static String getNumDouble(double dou, int num) { String retValue = null; DecimalFormat df = new DecimalFormat(); df.setMinimumFractionDigits(0); df.setMaximumFractionDigits(num); ... 阅读全文
posted @ 2012-09-08 18:16 程序学习笔记 阅读(2347) 评论(0) 推荐(0) 编辑
摘要: /** * 把"yyyy-MM-dd HH:mm:ss"格式日期转换成毫秒 *@param strDate *@return 转换后毫秒的值 *@author hongj */ public long paseDateTomillise(String strDate){ String year = null; String month = null; String day = ""; String hms = ""; if(strDate.contains(" ") && ... 阅读全文
posted @ 2012-09-08 18:15 程序学习笔记 阅读(2940) 评论(0) 推荐(0) 编辑
摘要: import java.util.regex.Matcher;import java.util.regex.Pattern;public class StringUtils { public static String replaceBlank(String str) { String dest = ""; if (str!=null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest... 阅读全文
posted @ 2012-09-08 18:14 程序学习笔记 阅读(3760) 评论(0) 推荐(0) 编辑
摘要: 针对定位服务,android的API里提供了LocationManager这么一个类通过getLastKnownLocation(String provider)以及requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener)方法可以获取到当前位置此类提供两种定位方式:GPS定位和网络定位(基站+WIFI)GPS定位的provider是LocationManager.GPS_PROVIDER, 网络定位则是LocationManager.NETWORK_.. 阅读全文
posted @ 2012-09-08 17:51 程序学习笔记 阅读(12034) 评论(1) 推荐(1) 编辑
摘要: import android.app.Activity;import android.app.AlertDialog;import android.content.DialogInterface;import android.content.DialogInterface.OnMultiChoiceClickListener;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.w 阅读全文
posted @ 2012-09-08 17:47 程序学习笔记 阅读(2836) 评论(0) 推荐(0) 编辑
摘要: 阅读全文
posted @ 2012-09-08 17:23 程序学习笔记 阅读(151) 评论(0) 推荐(0) 编辑
摘要: Android 对中文字体支持很不好~~ 需要加入相应的字体库(1)创建布局Layout//创建线性布局 LinearLayout linearLayout=newLinearLayout(this); //设定线性布局为垂直方向 linearLayout.setOrientation(LinearLayout.VERTICAL); //以该线性布局做视图 setContentView(linearLayout);(2)针对正常字体 //普通正常字体 normal=newTextView(thi... 阅读全文
posted @ 2012-09-08 17:19 程序学习笔记 阅读(443) 评论(0) 推荐(0) 编辑
摘要: /** * 分别获取一个字符串里面的中文和其他字符所占的字节数 */ public static int getLength(String str){ int strLength = 0; String chinese = "[\u0391-\uFFE5]"; /* * 获取字符串长度,如果含有中文字符,则每个中文字符占2个字符长度,否则为1 */ for (int i = 0; i < str.length(); i++) { /* ... 阅读全文
posted @ 2012-09-08 17:12 程序学习笔记 阅读(328) 评论(0) 推荐(0) 编辑
摘要: 1 先定义如下EditText和TextWatcher : 2 EditText editText; 3 TextWatcher textWatcher; 4 5 (如下代码放在一个方法中) 6 7 editText.addTextChangedListener(textWatcher); 8 textWatcher = new TextWatcher() { 9 10 @Override11 public void onTextChanged(CharSequence s, int ... 阅读全文
posted @ 2012-09-08 17:02 程序学习笔记 阅读(610) 评论(0) 推荐(0) 编辑
摘要: 本文介绍Android中关于Activity的两个神秘方法:onSaveInstanceState和onRestoreInstanceState。 关于这两个方法,一些朋友可能在Android开发很少用到,但在有时候掌握其用法会帮我们起到比较好的效果。 1. 基本作用简介: Activity的 onSaveInstanceState() 和 onRestoreInstanceState()并不是生命周期方法,它们不同于 onCreate()、onPause()等生命周期方法,它们并不一定会被触发。当应用遇到意外情况(如:内存不足、用户直接按Home键)由系统销毁一个Activity时,on.. 阅读全文
posted @ 2012-06-06 23:54 程序学习笔记 阅读(285) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 10 下一页