首页 > 系统 > Android > 正文

android 格式化本地时间

2019-11-09 16:45:40
字体:
来源:转载
供稿:网友

简单易用格式化本地时间的方法:

DateFormat dateInstance = getDateInstance(); DateFormat dateTimeInstance = getDateTimeInstance(); DateFormat timeInstance = getTimeInstance(); String s1 = dateInstance.format(new Date()); String s2 = dateTimeInstance.format(new Date()); String s3 = timeInstance.format(new Date()); System.out.PRintln("huwei: "+s1);//2017年2月8日 System.out.println("huwei: "+s2);//2017年2月8日 下午5:39:50 System.out.println("huwei: "+s3);//下午5:41:17

ImageView 的contentDescription属性 : 如果您控件的图片没有设置或图片找不到啦,显示不出来了,就显示contentDescription的设置文字!

在代码中动态设置TextView的drawableLeft属性:

Drawable drawable= getResources().getDrawable(R.drawable.drawable); /// 这一步必须要做,否则不会显示. drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); myTextview.setCompoundDrawables(drawable,null,null,null);
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表