随笔分类 -  android

android的知识
摘要://去掉窗口 requestWindowFeature(Window.FEATURE_NO_TITLE);(一定要放在setContentView(R.layout.main)的前面) //全屏显示 getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); 阅读全文
posted @ 2013-06-21 22:16 程序学习笔记 阅读(253) 评论(0) 推荐(0) 编辑
摘要:view_show.xml<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> 阅读全文
posted @ 2013-06-21 22:04 程序学习笔记 阅读(297) 评论(0) 推荐(0) 编辑
摘要:// 获取编辑框焦点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 程序学习笔记 阅读(2371) 评论(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 程序学习笔记 阅读(3533) 评论(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 程序学习笔记 阅读(12017) 评论(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 程序学习笔记 阅读(2823) 评论(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) 编辑
摘要:本文介绍Android中关于Activity的两个神秘方法:onSaveInstanceState和onRestoreInstanceState。 关于这两个方法,一些朋友可能在Android开发很少用到,但在有时候掌握其用法会帮我们起到比较好的效果。 1. 基本作用简介: Activity的 onSaveInstanceState() 和 onRestoreInstanceState()并不是生命周期方法,它们不同于 onCreate()、onPause()等生命周期方法,它们并不一定会被触发。当应用遇到意外情况(如:内存不足、用户直接按Home键)由系统销毁一个Activity时,on.. 阅读全文
posted @ 2012-06-06 23:54 程序学习笔记 阅读(285) 评论(0) 推荐(0) 编辑
摘要:本文来自http://blog.csdn.net/hellogv/ ,引用必须注明出处! 前面写了十四篇关于界面的入门文章,大家都看完和跟着练习之后,对于常用的Layout和View都会有一定的了解了,接下来的文章就不再强调介绍界面了,而是针对具体的常见功能而展开。 本文介绍MediaPlayer的使用。MediaPlayer可以播放音频和视频,另外也可以通过VideoView来播放视频,虽然VideoView比MediaPlayer简单易用,但定制性不如用MediaPlayer,要视情况选择了。MediaPlayer播放音频比较简单,但是要播放视频就需要SurfaceView。Surface 阅读全文
posted @ 2012-05-06 22:45 程序学习笔记 阅读(694) 评论(0) 推荐(0) 编辑
摘要:直接上代码:步骤:01.先创建一个类继承AppWidgetProviderpackage com.senk.appwidget;import android.app.PendingIntent;import android.appwidget.AppWidgetManager;import android.appwidget.AppWidgetProvider;import android.content.Context;import android.content.Intent;import android.util.Log;import android.widget.RemoteViews 阅读全文
posted @ 2012-04-22 17:50 程序学习笔记 阅读(597) 评论(0) 推荐(0) 编辑