Add Row to EfficiencyAdapter

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

Add Row to EfficiencyAdapter

Postby guruk » Wed Mar 18, 2009 4:13 pm

Hi,
i have a Efficiency Adapter with extra Rows and Holders.

How would I ADD just a new row when I keep the List in the beginning clean.
Or how do I have to initialize this Adapter empty. Short Tut or demo would be great

Just important I like a listview, with rows that have pic and text and i like to add
, delete, change items

here is my code till now


private static class EfficientAdapter extends BaseAdapter {
private LayoutInflater mInflater;

public EfficientAdapter(Context context) {


mInflater = LayoutInflater.from(context);


}

public void add(String string)
{
// TODO Auto-generated method stub

}

/**
* The number of items in the list is determined by the number of speeches
* in our array.
*
* @see android.widget.ListAdapter#getCount()
*/
public int getCount() {
return 0;
//return mStrings.length;
}

public void setSelected(int index) {
// notify the model that the data has changed, need to update the view
notifyDataSetChanged();
}

/**
* Since the data comes from an array, just returning the index is
* sufficent to get at the data. If we were using a more complex data
* structure, we would return whatever object represents one row in the
* list.
*
* @see android.widget.ListAdapter#getItem(int)
*/
public Object getItem(int position) {
return position;
}

/**
* Use the array index as a unique id.
*
* @see android.widget.ListAdapter#getItemId(int)
*/
public long getItemId(int position) {
return position;
}

/**
* Make a view to hold each row.
*
* @see android.widget.ListAdapter#getView(int, android.view.View,
* android.view.ViewGroup)
*/
public View getView(int position, View convertView, ViewGroup parent) {

ViewHolder holder;


if (convertView == null) {
convertView = mInflater.inflate(R.layout.row, null);


holder = new ViewHolder();
holder.text = (TextView) convertView.findViewById(R.id.label);
holder.text2 = (TextView) convertView.findViewById(R.id.label2);
holder.icon = (ImageView) convertView.findViewById(R.id.icon);

convertView.setTag(holder);
} else {

holder = (ViewHolder) convertView.getTag();
}

// Bind the data efficiently with the holder.
holder.text.setText("123");
holder.text2.setText("aaaaa");
holder.icon.setImageBitmap(lPics[position]);

holder.icon.setAdjustViewBounds(true);
holder.icon.setScaleType(ImageView.ScaleType.FIT_XY);
holder.icon.setMaxHeight(48);


return convertView;
}

static class ViewHolder {
TextView text;
TextView text2;
ImageView icon;
}

}


thanks chris
guruk
Junior Developer
Junior Developer
 
Posts: 24
Joined: Sun Mar 08, 2009 8:05 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 8 guests