摘要: // 获取编辑框焦点editText.setFocusable(true);//打开软键盘InputMethodManager imm = (InputMethodManager) ctx .getSystemService(Context.INPUT_METHOD_SERVICE);imm.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);//关闭软键盘imm.hideSoftInputFromWindow(editText.getWindowToken(), 0); 阅读全文
posted @ 2012-09-08 19:43 程序学习笔记 阅读(859) 评论(0) 推荐(0) 编辑
摘要: /** * 测试网络是否已连接 * * @param retryCount * 重试次数,如果为0,则不重试 * @param retryDelayTimes * 重试时间间隔(单位:秒) * @return true表示已连接,否则为false */ public boolean testNetConnected(int retryCount, int retryDelayTimes) { boolean flag = isNetConnected();//... 阅读全文
posted @ 2012-09-08 19:01 程序学习笔记 阅读(514) 评论(0) 推荐(0) 编辑
摘要: 调用系统拍照// 如果点击的是拍照按钮case R.id.btn_map_camera: { Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(intent, CAMERA_REQUESTCODE); } break;// 调用系统的方法,进入拍照界面 /** * 回调和拍照功能 */ @Override protected void onActivityResul... 阅读全文
posted @ 2012-09-08 18:41 程序学习笔记 阅读(445) 评论(0) 推荐(0) 编辑
摘要: /** * 判断SD卡的剩余容量 * */ public long isAvaiableSpace(int sizeMb) { long availableSpare = 0; if (android.os.Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED)) { String sdcard = Environment.getExternalStorageDirectory().getPath(... 阅读全文
posted @ 2012-09-08 18:29 程序学习笔记 阅读(578) 评论(0) 推荐(0) 编辑
摘要: /** * 获取时间差xx小时xx分钟前 *@param newTime 新时间 2012-6-12 13:57:43 *@param oldTime 老时间 2012-6-12 10:52:48 *@return 描述 *@author hongj */ private String getTimeGap(String newTime,String oldTime){ String hDes = ""; String mDes = ""; String[] newtime = ne... 阅读全文
posted @ 2012-09-08 18:24 程序学习笔记 阅读(498) 评论(0) 推荐(0) 编辑
摘要: <shape> <!-- 实心 --> <solid android:color="#ff9d77"/> <!-- 渐变 --> <gradient android:startColor="#ff8c00" android:endColor="#FFFFFF" android:angle="270" /> <!-- 描边 --> <stroke android:width="2dp" android:color=&qu 阅读全文
posted @ 2012-09-08 18:19 程序学习笔记 阅读(2372) 评论(0) 推荐(0) 编辑
摘要: /** * 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 程序学习笔记 阅读(3600) 评论(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 程序学习笔记 阅读(12025) 评论(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 程序学习笔记 阅读(2824) 评论(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 程序学习笔记 阅读(609) 评论(0) 推荐(0) 编辑