Everything was working fine but now I am not getting what is happening,I have 72 items to display in the listView,its don't working fine first item display at 3rd position and other item that it repeats again from the 1st item again??
package com.example.kishorsinh.yogaapp.Adapter;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;
import com.example.kishorsinh.yogaapp.Model.InstructionsData;
import com.example.kishorsinh.yogaapp.R;
import java.util.List;
public class InstructionsAdapter extends BaseAdapter {
Context applicationContext;
List<InstructionsData> iData;
public InstructionsAdapter(Context applicationContext, List<InstructionsData> iData) {
this.applicationContext=applicationContext;
this.iData=iData;
}
@Override
public int getCount() {
return iData.size();
}
@Override
public Object getItem(int position) {
return iData.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
MyViewHolder myViewHolder;
if(convertView==null)
{
LayoutInflater layoutInflater=(LayoutInflater) applicationContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView=layoutInflater.inflate(R.layout.instructions_list,parent,false);
myViewHolder=new MyViewHolder();
myViewHolder.imageView=(ImageView) convertView.findViewById(R.id.inst_image);
myViewHolder.textView1=(TextView) convertView.findViewById(R.id.inst_name);
//myViewHolder.textView2=(TextView) convertView.findViewById(R.id.detail_inst);
InstructionsData instructionsData=iData.get(position);
myViewHolder.imageView.setImageResource(instructionsData.getImage_inst());
myViewHolder.textView1.setText(instructionsData.getInstructionslist());
//myViewHolder.textView2.setText(instructionsData.getInstructionslist());
convertView.setTag(myViewHolder);
}
else
{
myViewHolder=(MyViewHolder)convertView.getTag();
}
return convertView;
}
private class MyViewHolder
{
ImageView imageView;
TextView textView1;
//TextView textView2;
}
}
it just repeat all name of list you can see in image below...
As you say
its don't working fine first item display at 3rd position and other item that it repeats again from the 1st item again
you need to bind data without any condition for each item like you are only binding data when converconvertView == null
so just remove this
if(convertView==null)
condition and always bind data without any condition