1.在application xml中使用全局的theme
2.利用runOnUiThread确保某个runnable运行在ui 线程里
3.利用<selector <item设置button背景而不是普通的图片作为背景
4.在listView getView中利用Holer来实现图片文字的缓存,以使得listView滑动高效,避免出现无限制的调用findViewById使得多次DOM解析xml带来的低效率
static class ViewHolder { protected TextView title; protected TextView type; }
public View getView(int position, View contentView, ViewGroup arg2) { ViewHolder holder; if (contentView == null) { holder = new ViewHolder(); contentView = inflater.inflate(R.layout.my_magic_list,null); holder.label = (TextView) contentView.findViewById(R.id.label); contentView.setTag(holder); } else { holder = (ViewHolder) contentView.getTag(); } holder.label.setText(getLabel()); return contentView; }
在view.setTag缓存了Holer,Holer中保存了TextView,Java中是值传递,Holder中的textView和converView中的textView是同一个对象,所以当修改了对应行holder中的textview就同时修改了对应行中的
避免了多次调用findViewById
5.android:cacheColorHint=”@android:color/transparent”防止listView滚动时候的触摸阴影
6.EditText setError可以给出错误提示
7.阻止默认的startActivty的动画 myIntent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION)
8.TextView 多行显示 android:singleLine=”false”, android:lines=”5″
9.多利用xml来绘制重叠图片