Android工具类
来源:互联网 发布:推荐les淘宝店 编辑:程序博客网 时间:2024/06/05 22:56
import java.text.ParseException;import java.text.SimpleDateFormat;import java.util.Date;import android.os.Handler;import android.text.TextUtils;import android.view.View;import android.widget.AbsListView;import android.widget.TextView;import com.sinolbs.ecd.R;public class CommonUtils {public static String getAgeByDateTime(String dateTime) {String year = null;SimpleDateFormat myFormatter = new SimpleDateFormat("yyyy-MM-dd"); java.util.Date date=new Date(); java.util.Date mydate;try {mydate = myFormatter.parse(dateTime);long day=(date.getTime()-mydate.getTime())/(24*60*60*1000) + 1;year=new java.text.DecimalFormat("#").format(day/365f);} catch (ParseException e) {e.printStackTrace();}return year;}/** * 将字符串时间转换为毫秒值 * @param str * @return */public static long getTimeStemp(String str){ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); Date d = null; try { if (!TextUtils.isEmpty(str)) { d = sdf.parse(str); return d.getTime();} } catch (ParseException e) { e.printStackTrace(); } return 0; }public static void setCollTextBg(TextView item_constellation , String constellation){//改变背景的颜色if ("白羊座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.baiyang);}else if ("金牛座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.jinniu);}else if ("双子座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.shuangzi);}else if ("巨蟹座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.juxie);}else if ("狮子座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.shizi);}else if ("处女座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.chunv);}else if ("天秤座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.tiancheng);}else if ("天蝎座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.tianxie);}else if ("射手座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.sheshou);}else if ("摩羯座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.mojie);}else if ("水瓶座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.shuiping);}else if ("双鱼座".equals(constellation)) {item_constellation.setBackgroundResource(R.color.shuangyu);}else {item_constellation.setVisibility(View.GONE);}}public static void scrollToListviewTop(final AbsListView listView){ listView.smoothScrollToPosition(0); final Handler handler = new Handler(); handler.postDelayed(new Runnable() { @Override public void run() { if (listView.getFirstVisiblePosition() > 0) { //listView.smoothScrollToPosition(0); listView.setSelection(0); handler.postDelayed(this, 100); } } }, 100); }}
0 0
- 【Android工具】时间工具类
- [Android工具类]Android File工具类
- Android Bitmap 工具类
- Android:HttpClient工具类
- android图片下载工具类
- android日志工具类
- android ---- ImageUtil工具类
- Android Bitmap 工具类
- android 图片工具类
- Android 工具类
- android缓存工具类
- android截图工具类
- Android工具类
- Android工具类-SharedPrefsUtil
- Android 日志工具类
- Android ShareProference工具类
- android工具类归纳
- android 工具类
- 【NOIP 模拟题】[T2]分解数(线性筛+贪心)
- 浅谈 easyui tabs 的href和content属性
- windows下python装openpyxl 以及jdcal
- 剑指offer面试题14
- SpringMVC参数绑定注解
- Android工具类
- 链表增删查
- jQuery Mobile Data 属性
- UTF编码字符串的总字节数计算
- Android 联系人数据库contacts2.db介绍
- 406. Queue Reconstruction by Height
- /bin/bash: bison: command not found
- 你真的了解 load 方法么
- hdu 2203