android listView 中存在editView chetxBox等点击事件处理
2010-05-24 16:32:00 来源:WEB开发网* for faster access.
*/
public Object getItem(int position) {
return mDataObjects.get(position);
}
/**
* We use the array index as a unique id. That is, position equals id.
*
* @return The id of the object
*/
public long getItemId(int position) {
return position;
}
/**
* Make a view to hold each row. This method is instantiated for each list
* object. Using the Holder Pattern, avoids the unnecessary
* findViewById()-calls.
*/
public View getView(int position, View view, ViewGroup parent) {
// A ViewHolder keeps references to children views to avoid uneccessary
// calls
// to findViewById() on each row.
ViewHolder holder;
// When view is not null, we can reuse it directly, there is no need
// to reinflate it. We only inflate a new View when the view supplied
// by ListView is null.
if (view == null) {
view = mInflater.inflate(mViewId, null);
// call the user’s implementation
holder = createHolder(view);
// we set the holder as tag
view.setTag(holder);
} else {
// get holder back…much faster than inflate
holder = (ViewHolder) view.getTag();
}
// we must update the object’s reference
holder.data = getItem(position);
// call the user’s implementation
bindHolder(holder);
return view;
}
/**
* Creates your custom holder, that carries reference for e.g. ImageView
* and/or TextView. If necessary connect your clickable View object with the
* PrivateOnClickListener, or PrivateOnLongClickListener
*
* @param vThe view for the new holder object
更多精彩
赞助商链接