- 博客(152)
- 收藏
- 关注
原创 cleaning selected projects has encountered a problem errors occurred during build
clean 项目的时候出现的问题。 cleaning selected projects has encountered a problem errors occurred during build 错误:可能是eclipse 中运行的当前clean的项目直接退出一下eclipse就可以解决这个问题。
2015-08-06 10:01:32
3397
原创 Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPoi
Android开发中java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx}: java.lang.NullPointerException 错误的集中原因及解决办法今天学习Android开发突然遇到了这个问题,查阅了很多资料,并且对集中原因进行了分析。 错误信
2015-06-11 17:42:25
2865
原创 正则表达式
正则表达式,\\d表示 0-9 的数字,\\s表示 空格,回车,换行等空白符,\\w表示单词字符(数字字母下划线)+号表示一个或多个的意思,所以...
2015-05-27 19:58:17
792
原创 Java中split的用法
Java中的我们可以利用split把字符串按照指定的分割符进行分割,然后返回字符串数组,下面是string.split的用法实例及注意事项:java.lang.string.splitsplit 方法将一个字符串分割为子字符串,然后将结果作为字符串数组返回。stringObj.split([separator,[limit]]) stringObj必选项。要被分解的 Str
2014-11-12 11:29:36
49566
5
原创 android获取string.xml的值
为什么需要把应用中出现的文字单独存放在string.xml文件中呢?一:是为了国际化,当需要国际化时,只需要再提供一个string.xml文件,把里面的汉子信息都修改为对应的语言(如,English),再运行程序时,android操作系统会根据用户手机的语言环境和国家来自动选择相应的string.xml文件,这时手机界面就会显示出英文。这样做国际化非常的方便。二:为了减
2014-10-27 11:47:51
2149
原创 Workspace in use or cannot be created, choose a different one.--错误解决办法
eclipse 使用一段时间后,有时会因为一些故障自己就莫名奇妙的关闭了,再打开时有时没有问题,有时有会提示错误 Workspace Unavailable:Workspace in use or cannot be created, choose a different one.原因:出现这种情况一般是workspace的配置文件中出现了.lock文件(workspace
2014-10-16 10:23:39
1181
原创 network: Android 网络判断(wifi、3G与其他)
public class NetworkProber { /** * 网络是否可用 * * @param activity * @return */ public static boolean isNetworkAvailable(Context context) { ConnectivityManager connectivity = (Connectivit
2014-10-15 17:29:25
1112
原创 remotepath != null 与 !TextUtils.isEmpty(remotepath) 的区别
remotepath != null 与 !TextUtils.isEmpty(remotepath) 的区别 !TextUtils.isEmpty(remotepath) 与 remotepath != null &&remotepath.length > 0 一样或者初始化 remotepath = null,这时只判断 remotepath != n
2014-10-11 14:16:41
2379
原创 日期和时间格式化
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 这一行最重要,它确立了转换的格式,yyyy是完整的西元年,MM是月份,dd是日期,HH:mm:ss是时分秒。为什麽有的格式大写,有的格式小写,那是怕避免混淆,例如MM是月份,mm是分;HH是24小时制,而hh是12小时制
2014-10-11 09:52:32
958
原创 获取Android系统语言设置
private int g_lag = 1; // String filename = Locale.getDefault().getLanguage();if (filename != null) {if (filename.equalsIgnoreCase("zh")) {g_lag = 1;} else if (filename.equalsIgnoreCase("en"
2014-09-30 14:12:16
1338
原创 java.lang.VerifyError解决方案
当坑爹的一个抛错,最近在开发一个邮箱的小应用,导入三个sun的开发jar包,坑爹的事情就这样发生了。无论我怎么修改代码,总是抛出java.lang.VerifyError的错误,一直以为是自己的代码处理上有问题,找来找去就是没发现错误啊,抓耳挠腮。想不通,自己写的一个类,错误定位在这个类创建对象时的语句出错,写了构造函数,不管怎么改都是抛错,苦苦寻找,就是没找到错误啊。一个函数一个函数的注释掉
2014-09-18 19:55:45
3537
原创 android三种载入图片方式
package smalt.music.utils; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BitmapFactory.Options; //加载图片的方法:3种 public class BitmapUntil {
2014-09-18 15:44:11
2150
1
原创 Android Activity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?
Android Activity为什么要细化出onCreate、onStart、onResume、onPause、onStop、onDesdroy这么多方法让应用去重载?原创链接:http://blog.youkuaiyun.com/zhao_3546/article/details/12843477,转载请注明,谢谢。最近在研究Activity的启动流程,老罗的blog在看,也找
2014-09-16 13:17:02
1203
1
原创 Utils.toDip()的用法
ivPhoto.setImageBitmap(photo);改为ivPhoto.setImageBitmap(Utils.getimage(photo,Utils.toDip(75),Utils.toDip(75)));
2014-09-16 10:54:11
930
原创 Android怎么结束一个进程,我试了用 ActivityManager.killBackgroundProcesses方法去结束,但是没有反应
在android2.2以后,如果服务在ondestroy里加上了start自己,用kill backgroudprocess通常无法结束自己。有一种最新发现的方法,利用反射调用forceStopPackage来结束进程Method forceStopPackage = am.getClass().getDeclaredMethod("forceStopPackage", String.clas
2014-09-13 15:44:15
3410
原创 android:descendantFocusability用法简析
开发中很常见的一个问题,项目中的listview不仅仅是简单的文字,常常需要自己定义listview,自己的Adapter去继承BaseAdapter,在adapter中按照需求进行编写,问题就出现了,可能会发生点击每一个item的时候没有反应,无法获取的焦点。原因多半是由于在你自己定义的Item中存在诸如ImageButton,Button,CheckBox等子控件(也可以说是Button或者C
2014-09-09 20:54:23
2562
原创 dp 与px互相转换
/** * 根据手机的分辨率从 dp 的单位 转成为 px(像素) */ public static int dip2px(Context context, float dpValue) { final float scale = context.getResources().getDisplayMetrics().density;
2014-09-09 14:10:17
1060
原创 倒计时的CountDownTimer
直接看这里吧,我只是搬运工。 定时执行在一段时候后停止的倒计时,在倒计时执行过程中会在固定间隔时间得到通知(译者:触发onTick方法),下面的例子显示在一个文本框中显示一个30s倒计时: Java代码 new CountdownTimer(30000, 1000) { public void onTick(long millisUntilFi
2014-09-08 18:42:50
2519
原创 TextWatcher() 的用法
实例一:phone_view.addTextChangedListener(new TextWatcher() {public void onTextChanged(CharSequence s, int start, int before, int count) {Log.i(TAG, "onTextChanged =" + s + " start:" + start + " b
2014-09-08 02:17:10
2423
原创 android 中ScrollView的使用
android中布局一般都有两种方式,一种xml声明,另外一种则是程序声明:xml:xml version="1.0" encoding="utf-8"?>LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent"
2014-09-08 01:11:19
2720
原创 androdi 中listview.setTextFilterEnabled(boolean)的作用
大概意思就是但listview获得当前焦点的时候,相应用户输入的匹配符。筛选出匹配的listview Items。 String[] menus = { "1信息查询","1信息采集","2文件上传","2GPS定位功能" }; setListAdapter(new ArrayAdapter(this, andro
2014-09-08 00:20:09
2373
原创 加载类初始化
private static void parseClassToLoad(XmlPullParser parser) throws Exception { String className = parser.nextText(); // Attempt to load the class so that the class can get initialized
2014-09-07 13:07:11
899
原创 通过本地存储的一个值和当前获取值得比较得到一个boolean值
/** * Sets the port of the local Socks5 proxy. Default is 7777. If you set the port to a negative * value Smack tries the absolute value and all following until it finds an open port.
2014-09-07 02:44:23
1401
原创 通过获取的一个值和本地的一个值比较来获取一个boolean值
/** * Sets the port of the local Socks5 proxy. Default is 7777. If you set the port to a negative * value Smack tries the absolute value and all following until it finds an open port.
2014-09-07 02:43:53
1443
原创 移除字符串中的字符和移除字符串数组中的字符
/** * Remove a SASL mechanism from the list to be used. * * @param mech the SASL mechanism to be removed */ public static void removeSaslMech(String mech) { if( d
2014-09-07 01:26:03
2790
原创 从smack-config.xml文件中加载文件内容 Loads the configuration from the smack-config.xml file
/** * Loads the configuration from the smack-config.xml file. * * So far this means that: * 1) a set of classes will be loaded in order to execute their static init block
2014-09-07 01:17:48
1651
原创 读取Assets中文件的内容
public InputStream getAssetsInputStream(String fileName) throws IOException {return getApplicationContext().getAssets().open(fileName);}
2014-09-05 13:32:23
724
原创 传text和resid的两种Toast的写法
public void showToast(String text) {CustomToast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();}public void showToast(int resId) {CustomToast.makeText(getApplicationCon
2014-09-05 13:29:00
931
原创 获取应用和安装手机相关信息:应用版本号,手机型号,手机品牌,Android系统版本号
/*** User-Agent* * @return user-agent*/public String getUser_Agent() {String ua = "Android;" + getOSVersion() + ";" + getVersion() + ";"+ getVendor() + "-" + getDevice();return ua;
2014-09-05 11:53:36
1376
原创 获取应用的版本号
/*** Retrieves application's version number from the manifest* * @return versionName*/public String getVersion() {String version = "0.0.0";try {PackageInfo packageInfo = getPackageMana
2014-09-05 11:37:53
735
原创 判断网络连接状态
/*** 判断网络连接状态*/public static boolean isNetworkAvailable(Context context) {ConnectivityManager cwjManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);Netw
2014-09-05 10:56:01
814
原创 通知群聊名称变化
/** * * This method is used :通知群聊名称变化 * @author tianwei * @version * 4.0 2014-9-5 上午10:50:39 */public static void notifyMembersMucNameChanged(String mJid, String roomJid,String
2014-09-05 10:52:21
1387
原创 监听SharedPreference变化的方法
/** * A listener for all the change in the preference file. It is used to maintain the global state of the application. */ private class PreferenceListener implements SharedPreference
2014-09-05 10:42:51
3083
原创 Android 返回桌面
/*** * 返回桌面* @param context*/public static void toHome(Context context ){Intent mHomeIntent = new Intent(Intent.ACTION_MAIN); mHomeIntent.addCategory(Intent.CATEGORY_HOME);
2014-09-04 20:21:16
1096
原创 Activity 中的Toast在Activity销毁后报错,解决方法,把context改成应用的
ToastUtil.showShort(context, R.string.connection_fail);改成ToastUtil.showShort(BusinesslinkApplication.getInstance(), R.string.connection_fail);
2014-09-03 11:30:36
1791
原创 Android应用的Tab键,来回反复点击会报ANR,是空指针导致的,判空就可以解决
getView().findViewById(R.id.iv_tip_update).setVisibility(View.VISIBLE);以前报空指针修改后if(getView()!=null&&getView().findViewById(R.id.iv_tip_update)!=null){getView().findViewById(R
2014-09-02 15:09:45
1129
原创 index 把@前的截断作为
/** * Returns the name portion of a XMPP address. For example, for the * address "matt@jivesoftware.com/Smack", "matt" would be returned. If no * username is present in the address,
2014-08-22 19:58:19
724
原创 java传入一个字符串 将它分割成大写字符为首的字符串数组
/* * 传入一个字符串 将它分割成大写字符为首的字符串数组 */ private ArrayList splitByUpperCase(String str) { ArrayList rs = new ArrayList(); int index = 0; int len = str.length();
2014-08-01 13:40:22
3303
原创 传入一个中文字符串,返回一个字符串中的中文拼音
/** * @param 传入一个中文字符串 * @return 返回一个字符串中的中文拼音 */ private String getNameNum(String name) { if (!Utils.isStrEmpty(name)) { int len = name.length();
2014-08-01 13:35:40
1060
原创 JAVA传入一个字符串,返回一个字符串中的大写字母
/** * * @param 传入一个字符串 * @return 返回一个字符串中的大写字母 */ private static String stringChange(String s) { if (Utils.isStrEmpty(s)) return ""; String
2014-08-01 13:35:07
3961
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人