随笔分类 -  Android

1
摘要:xml源码如下 ... 阅读全文
posted @ 2014-05-05 16:05 qiangzhu 阅读(2179) 评论(3) 推荐(0)
摘要:private static final int CONNECTION_TIMEOUT = 10000; public static String doHttpGet(String serverURL) throws Exception { HttpParams httpParameters = new BasicHttpParams(); HttpConnectionParams.setConnectionTimeout(httpParameters, CONNECTION_TIMEOUT); HttpConnectionParams.... 阅读全文
posted @ 2014-03-25 18:12 qiangzhu 阅读(14503) 评论(0) 推荐(0)
摘要:如何保证只有一个线程在运行,在启动线程的时候停止之前的线程?实例如下: private volatile Thread udpSendThread;线程:class UdpSender extends Thread { @Override public void run() { if (udpSendThread == null) { return; } // other work } }启动线程: private void startUdpSe... 阅读全文
posted @ 2014-03-11 17:15 qiangzhu 阅读(458) 评论(0) 推荐(0)
摘要:Fragment弹出toast,时不时出现getActivity()空指针,具体原因未查到。解决办法: if (null == fragment || !fragment.isAdded()) { return; }原地址http://stackoverflow.com/questions/11631408/android-fragment-getactivity-sometime-returns-null 阅读全文
posted @ 2014-03-11 17:06 qiangzhu 阅读(7501) 评论(0) 推荐(0)
摘要:public class WifiAutoConnectManager {private static final String TAG = WifiAutoConnectManager.class.getSimpleName();WifiManager wifiManager; // 定义几种加密方式,一种是WEP,一种是WPA,还有没有密码的情况 public enum WifiCipherType { WIFICIPHER_WEP, WIFICIPHER_WPA, WIFICIPHER_NOPASS, WIFICIPHER_INVALID } // 构造函数 ... 阅读全文
posted @ 2014-02-25 14:39 qiangzhu 阅读(34232) 评论(3) 推荐(1)
摘要:分辨率适配的出发点:a.根据不同的屏幕尺寸提供UI布局(layout)。 b.根据不同屏幕像素密度(单位英寸的像素值)提供界面元素的图片。1.基本概念Screen size-屏幕尺寸(Actual physical size, measured as the screen's diagonal.For simplicity, Android groups all actual screen sizes into four generalized sizes: small, normal, large, and extra large.)手机实际的物理尺寸,指屏幕对角线的长度,比如2.8 阅读全文
posted @ 2013-03-08 19:59 qiangzhu 阅读(2303) 评论(0) 推荐(0)
摘要:比图android旋转屏幕,又竖屏到横屏,activity的生命周期onPause->onStop->onDestroy->onCreate->onStart->OnResumeAPI level 13 or higher,you should set this config instead:android:configChanges="orientation|screenSize"然后旋转屏幕,只会调用onConfigurationChanged,不会创建新activity. 阅读全文
posted @ 2013-03-08 16:59 qiangzhu 阅读(956) 评论(0) 推荐(0)
摘要:public static boolean isMediaScannerScanning(Context context) { boolean result = false; Cursor cursor = query(context, MediaStore.getMediaScannerUri(), new String [] { MediaStore.MEDIA_SCANNER_VOLUME }, null, null, null); if (cursor != null) { if (cursor.getCount() == 1) { cursor.moveToFirst(); re.. 阅读全文
posted @ 2013-03-06 14:32 qiangzhu 阅读(434) 评论(0) 推荐(0)
摘要:Most of the time you need to create a Service to perform something in the background, and your visible Activity simply controls this Service. (I'm sure the Music player works in the same way, so the example in the docs seems a bit misleading.) If that's the case, then your Activity can finis 阅读全文
posted @ 2013-02-28 15:17 qiangzhu 阅读(178) 评论(0) 推荐(0)
摘要:http://guibin.iteye.com/blog/1014369 阅读全文
posted @ 2013-02-18 13:17 qiangzhu 阅读(181) 评论(0) 推荐(0)
摘要:重新生成的key加入:ssh-add ~/.ssh/id_rsa 阅读全文
posted @ 2013-02-02 13:58 qiangzhu 阅读(268) 评论(0) 推荐(0)
摘要:当前的activity切换到后台,切换语言,回到原来的activity,原来的activity不见,出现又一新activity。原因:没有在AndroidManifest.xml 中申明android:configChangesandroid:configChangesLists configuration changes that the activity will handle itself. When a configuration change occurs at runtime, the activity is shut down and restarted by default, 阅读全文
posted @ 2013-01-22 16:08 qiangzhu 阅读(3763) 评论(0) 推荐(0)
摘要:1.方法一View Code private void initScrollBar() { try { Field f = AbsListView.class.getDeclaredField("mFastScroller"); f.setAccessible(true); Object o = f.get(mListView); f = f.getType().getDeclaredField("mThumbDrawable"); f.setAccessible... 阅读全文
posted @ 2013-01-22 14:24 qiangzhu 阅读(3566) 评论(0) 推荐(0)
摘要:<TextView android:layout_width="100px" android:layout_height="wrap_content" android:ellipsize="marquee" android:focusable="true" android:focusableInTouchMode="true" android:marqueeRepeatLimit="marquee_forever" android:scrollHorizontally= 阅读全文
posted @ 2012-12-28 12:43 qiangzhu 阅读(147) 评论(0) 推荐(0)
摘要:private OnItemClickListener listener = new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { } };mListView.setOnItemClickListener(listener);原因是ListView中有ImageButton,把ImageButton改为ImageView,ImageView 不会把事件发... 阅读全文
posted @ 2012-12-27 18:40 qiangzhu 阅读(897) 评论(0) 推荐(0)
摘要:1.Use android:maxEms to specify a maximum amount of characters2.set android:singleLine="false" 阅读全文
posted @ 2012-12-27 17:57 qiangzhu 阅读(18414) 评论(0) 推荐(0)
摘要:1.把milliseconds转为hh:mm:ssView Code 1 public static String formatMillisecondsToString(long millisecond) { 2 int hour = 0; 3 int minute = 0; 4 5 int second = (int) millisecond / 1000; 6 if (second >= 60) { 7 minute = second / 60; 8 second =... 阅读全文
posted @ 2012-11-30 15:11 qiangzhu 阅读(180) 评论(0) 推荐(0)
摘要:ubuntu系统下,adb不是内部命令 1.sudo gedit ~/.bashrc 2.在文档末尾加入 export PATH=$PATH:/home/android-sdks/platform-tools OK 搞定! 阅读全文
posted @ 2012-11-30 11:09 qiangzhu 阅读(1682) 评论(0) 推荐(0)
摘要:提示“设置无法完成 无法与服务器建立连接”,出现这个问题的可能原因是服务器没设置正确,不是默认的"gmail.com",要改成"m.google.com" 阅读全文
posted @ 2012-09-06 18:38 qiangzhu 阅读(3660) 评论(0) 推荐(0)
摘要:出现问题:1.windows中android SDK manager安装更新sdk很慢,或者出现Done loading packages后不动甚至没有任何可用包2.Failed to fetch URL https://dl-ssl.google.com/android/repository/repository-6.xml, reason: Connection to https://dl-ssl.google.com refusedFailed to fetch URL http://dl-ssl.google.com/android/repository/addons_list-1.x 阅读全文
posted @ 2012-09-05 14:51 qiangzhu 阅读(12265) 评论(0) 推荐(1)

1