android listView 中存在editView chetxBox等点击事件处理
2010-05-24 16:32:00 来源:WEB开发网* a TextView and an ImageView.
* @author poss3x
*/
public class ClickableListItemActivity extends ListActivity {
/**
* Our data class. This data will be bound to
* MyViewHolder, which in turn is used for the
* ListView.
*/
static class MyData {
public MyData(String t, boolean e) {
text = t;
enable = e;
}
String text;
boolean enable;
}
/**
* Our very own holder referencing the view elements
* of our ListView layout
*/
static class MyViewHolder extends ViewHolder {
public MyViewHolder(TextView t, ImageView i) {
text = t;
icon = i;
}
TextView text;
ImageView icon;
}
/**
* The implementation of ClickableListAdapter
*/
private class MyClickableListAdapter extends ClickableListAdapter {
public MyClickableListAdapter(Context context, int viewid,
List objects) {
super(context, viewid, objects);
// nothing to do
}
protected void bindHolder(ViewHolder h) {
// Binding the holder keeps our data up to date.
// In contrast to createHolder this method is called for all items
// So, be aware when doing a lot of heavy stuff here.
// we simply transfer our object’s data to the list item representatives
MyViewHolder mvh = (MyViewHolder) h;
MyData mo = (MyData)mvh.data;
mvh.icon.setImageBitmap(
mo.enable ? ClickableListItemActivity.this.mIconEnabled
: ClickableListItemActivity.this.mIconDisabled);
mvh.text.setText(mo.text);
}
@Override
protected ViewHolder createHolder(View v) {
更多精彩
赞助商链接