Hi Every one I'm facing with a problem in android what i need is I'm having a list view in my Fragment which is dynamically set with the values from database, my list view view updating the list dynamically in that i am having 8 items the list showing the first 5 items and repeating the from the first my code is like this.please help me in this thanks in advance.please help me in this i am not able to find what is the error. I have created the list view using Baseadapter.Thanks in advance
class FashionAdapter extends BaseAdapter
{
Context context;
String redu[];
JSONArray article;
LayoutInflater inflater;
private List<Fashion> articlelist;
FashionAdapter(JSONArray article, Context context) {
this.context = context;
this.article = article;
//this.content=content;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return article.length();
}
@Override
public Object getItem(int position) {
try {
return article.getJSONObject(position);
} catch (JSONException e) {
e.printStackTrace();
return null;
}
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ViewHolder holder;
Typeface font = Typeface.createFromAsset(getActivity().getAssets(), "fonts/eenadu-webfont.ttf");
if (convertView == null) {
convertView = LayoutInflater.from(getActivity()).inflate(
R.layout.fashoinlist_item, null);
Log.d("item postion",""+ position);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
JSONObject FasionObject;
try {
FasionObject=article.getJSONObject(position);
holder.fTitle.setText(FasionObject.getString("articletitle"));
holder.fsadec.setText(FasionObject.getString("articleshortdec"));
holder.fTitle.setTypeface(font);
holder.fsadec.setTypeface(font);
String articlThumImage=FasionObject.getString("articlethumbimg");
Picasso.with(getActivity()).load(articlThumImage).into(holder.fImage);
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
holder = (ViewHolder) convertView.getTag(); // return last set view of ith item
}
return convertView;
}
}
i was written the view hloder class like this, in this i intilized all the views . class ViewHolder {
ImageView fImage;
TextView fsadec,fTitle;
public ViewHolder(View itemView) {
fImage = (ImageView) itemView.findViewById(R.id.fashion_image);
fsadec=(TextView) itemView.findViewById(R.id.fashion_sdec);
fTitle=(TextView) itemView.findViewById(R.id.fashion_title);
}
please help me in this i am not able to find what is the error.