i am again here with one issue i want to crate a custom view of list item with imageview and textview\'s and also i need to add header\'s on specific positions. i never use
I understood it a little bit. You should add more attribute like header
in your model.
If your header
= true and in your adapter
class, then you have to inflate the layout header.xml
. Otherwise, if header
= false, then you should inflate your xml file i.e. (TextView
,ImageView
) as normal.
Here separator
in my code is the same as your header
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final recordModel model = records.get(position);
ViewHolder holder;
convertView = null;
holder = new ViewHolder();
if(records.get(position).getSeparator()==0){
convertView = inflater.inflate(R.layout.record_row, null);
convertView.setTag(holder);
holder.imageView = (ImageView) convertView
.findViewById(R.id.iconCallType);
holder.title = (TextView) convertView.findViewById(R.id.title);
holder.note = (TextView) convertView.findViewById(R.id.note);
holder.checkBox = (CheckBox) convertView.findViewById(R.id.check_box);
..........................
}else if(records.get(position).getSeparator()==1){
convertView = inflater.inflate(R.layout.separator, null);
convertView.setTag(holder);
holder.title = (TextView) convertView.findViewById(R.id.textSeparator);
holder.title.setText(records.get(position).getCallDay());
}
return convertView;
}
We do have a lot of amazing tutorials for the same, check some examples below:-
Android Section List
Android Amazing ListView
Do let us know, if you have to deal anu issue while doing it or have to go for any specific requirements to complete it.
You can add your own Header at any specific position using getItemViewType() and getViewTypeCount(). Here is a nice blog that explain everything about using these methods.