简单易用格式化本地时间的方法:
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:17ImageView 的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);新闻热点
疑难解答