空空的天空
sdkongkong · 共 35 篇文章
How to get width/height of a View
Email ThisBlogThis!Share to TwitterShare to FacebookShare to Pinterest As the idea of the Android evolved, Android has received wide attention and deployed on a very wide range of devices. Android UI had to move and make developers' life easier: AbsoluteLayout got deprecated. It is very logical bec…
2014-10-20 15:48 · 评论(0)
How to add source to eclipse for support v4
I just want to add yet another method of attaching sources for the support library. It requires ADT in version 20 or later. Supposedly this method works for all JARs for which setting source/javadoc location is disabled by the container. Here's what you need to do: The android-support-v4.jar librar…
2014-09-28 17:30 · 评论(0)
讯飞demo
package com.example.keda; import java.io.UnsupportedEncodingException; import android.app.Activity; import android.os.Bundle; import android.os.Environment; import android.text.TextUtils; import android.util.Log; import android.view.Menu; import android.view.View; import android.view.View.OnClickLi…
2014-09-03 12:20 · 评论(0)
埋码改进
package com.gome.ecmall.util; import android.app.Activity; import android.content.Context; import android.text.TextUtils; import com.gome.ecmall.app.AppConfig; import com.gome.ecmall.bean.GlobalConfig; import com.gome.eshopnew.R; import com.omniture.AppMeasurement; /** 数据统计--工具类 获取一个统计实例 ,并初始化常用的参数…
2014-07-03 10:23 · 评论(0)
服务器端和客户端交互时的压缩
服务器端: private byte compress(byte data) throws Exception { ByteArrayOutputStream baos = new ByteArrayOutputStream(); // 压缩 GZIPOutputStream gos = new GZIPOutputStream(baos); gos.write(data, 0, data.length); gos.finish(); byte output = baos.toByteArray(); baos.flush(); baos.close(); return output; } …
2013-12-10 09:07 · 评论(0)
adapter 调用notifydatasetchanged不刷新listview
the issue you're having is that you're overwriting the entries reference and it's not getting changed on the adapter. Here's how you can fix this @Override public void onResume() { super.onResume(); entries.clear(); entries.addAll(contactStorage.getContactListNames()); adapter.notifyDataSetChanged(…
2013-11-30 15:36 · 评论(0)
url-encode中文的乱码问题(转)
中文乱码在java中URLEncoder.encode方法要调用两次解决 因为在jsp中对中文进行了编码的时候用的是UTF-8的编码方式,而在servlet中调用request.getParameter();方法的时候使用服务器指定的编码格式自动解码一次,所以前台编码一次后台解码一次而解码和编码的方式不用所以造成了乱码的出现, 这就类似于以下代码: String name=java.net.URLEncoder.encode("测试", "UTF-8"); System.out.println(name); System.out.println(java.net.URLDecoder.dec…
2013-11-25 19:43 · 评论(0)
sqlite 比较时间字符串
String args = {uploadedStatus,"2013-01-01",date}; String sql = "select * from TPersonalTaskResult where isUploaded=? and Date(substr(timeStamp,1,10)) between Date(?) and Date(?)"; 其中substr是指从第几个字符串起截取几个 , 注意从0开始, 不是从1开始
2013-11-22 16:11 · 评论(0)
手机常用方法, 获取电池电量,信号强度,sd存储容量等
package com.nancal.pdaclient.util; import java.io.File; import android.content.Context; import android.content.Intent; import android.content.IntentFilter; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.BatteryManager; import android.os.Environment; import …
2013-10-23 18:48 · 评论(0)
消息推送中碰到的问题
1 报错: java.security.KeyStoreException: java.security.NoSuchAlgorithmException: KeyStore jks implementation not found 原因: 需要SASL验证,取消掉此验证。代码: view plaincopy configuration.setReconnectionAllowed(true); configuration.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled); configuration.setSend…
2013-10-22 15:32 · 评论(0)
给listview的item设置背景颜色--工作中遇到什么难题,怎么解决的
昨天准备把2个activity通过fragment继承到一个里面, 左边的fragment是一个listview,右边的是左边某个项目的详细信息。 遇到的问题是当点击昨天某一个listview的时候把背景设置成高亮或者改变背景颜色, google提供的fragment例子上是有个这个功能的。但是当我移植到自己的项目里时,该功能一直不起作用。上网查了一下,实现方法跟我的一样,就是使用setItemChecked. 于是我就重新阅读了google的示例代码,发现他使用的是ArrayAdapter,我用的是BaseAdapter,查了资料发现这2个类区别不大,就是多一个filter接口 , 于是把…
2013-09-27 10:16 · 评论(0)
屏幕适配的规则
屏幕大小不同 1:使用wrap_content 和 match_parent ,少用硬编码 2:使用RelativeLayout, 少用Linerlayout 3:使用多个pane, 例如fragment 4: 使用samll-width标志,例如res/layout-sw600dp/main.xml 5: 使用layout的别名 6: 7:使用9-patch图片 屏幕密度不同 1 使用dp,sp , 不用px 2 为xhdpi , 2.0 hdpi , mdpi 1.0 , ldpi 0.75 制作不同像素的图片
2013-09-23 20:33 · 评论(0)
复用convertview
public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if (convertView == null) { viewHolder = new ViewHolder(); convertView = LayoutInflater.from(mContext).inflate( R.layout.regular_safecheck_notuploaded_item, null); viewHolder.tvContent = (TextView) convert…
2013-09-23 16:22 · 评论(0)
更新listview显示在屏幕上的数据
ListView list = getListView(); int start = list.getFirstVisiblePosition(); for(int i=start, j=list.getLastVisiblePosition();i<=j;i++) if(target==list.getItemAtPosition(i)){ View view = list.getChildAt(i-start); list.getAdapter().getView(i, view, list); break; }
2013-09-10 21:03 · 评论(0)