简单易用格式化本地时间的方法:
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(s1);//2017年2月8日
System.out.println(s2);//2017年2月8日 下午5:39:50
System.out.println(s3);//下午5:41:17
ImageView 的contentDescription属性 :
如果您控件的图片没有设置或图片找不到啦,显示不出来了,就显示contentDescription的设置文字!
在代码中设置TextView的drawableLeft属性和改变图片的大小
使用TextView设置drawableLeft属性比用一个ImageView+一个TextView方便。
在代码中动态设置TextView的drawableLeft属性:
Drawable drawable= getResources().getDrawable(R.drawable.drawable);
/// 这一步必须要做,否则不会显示.
drawable.setBounds(0, 0, drawable