views:

15

answers:

0

Hi Please any one Help me out of this.. i am using listview adapter for displaying image list with check box, that allows to select multiple image form list.. code works good for images list not more than screen but if image is more than screen (for scrolling) it throws null pointer exception.. following is my code.

(apterMultiChoice.java)

public class PhotoAdapterMultiChoice extends BaseAdapter { public ViewHolder holder; private Activity activity; private ArrayList data; private ArrayList text; private ArrayList chkBox; private static LayoutInflater inflater=null; public ImageLoader imageLoader;

public PhotoAdapterMultiChoice(Activity a, ArrayList<String> title, ArrayList<String> URL,ArrayList<CheckBox> chkBoxPass) 
{
    activity = (Activity) a;
    data=URL;
    text=title;
    this.chkBox = chkBoxPass;
    inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    imageLoader=new ImageLoader(activity.getApplicationContext());
}
public int getCount() 
{
    return data.size();
}
public boolean getSelect(int position)
{
    return this.chkBox.get(position).isChecked();
}
public int getCountSelect()
{
    return chkBox.size();
}
public Object getItem(int position) 
{
    return this.chkBox.get(position).isChecked();
}
public long getItemId(int position) 
{
    return position;
}
public static class ViewHolder
{
    public TextView text;
    public ImageView image;
    public CheckBox checkBox;
}
public View getView(int position, View convertView, ViewGroup parent) 
{
    System.out.println(this.chkBox.size() +" ---- "+data.size());
    if(this.chkBox.size() < data.size())
    {
        View vi=convertView;
        if(convertView==null)
        {
            System.out.println("convertView is null");
            vi = inflater.inflate(R.layout.photoitemlistmultichoice, null);
            holder=new ViewHolder();
            holder.text=(TextView)vi.findViewById(R.id.text);
            holder.image=(ImageView)vi.findViewById(R.id.image);
            holder.checkBox=(CheckBox) vi.findViewById(R.id.check);
            //this.chkBox.add((CheckBox) vi.findViewById(R.id.check));
            vi.setTag(holder);
        }
        else 
        {
            System.out.println("convertView is Not null");
            this.chkBox.add((CheckBox) vi.findViewById(R.id.check));
            holder=(ViewHolder)vi.getTag();
        }

        System.out.println("Position : "+position);
        holder.text.setText(text.get(position));
        holder.image.setTag(data.get(position));
        //holder.checkBox.setTag(chkBox.get(position));
        //this.chkBox.set(position, chkBox.get(position));
        //this.chkBox.add(holder.checkBox);
        imageLoader.DisplayImage(data.get(position), activity, holder.image,"Photo");
        return vi;
    }
    return null;
}

}

How i call adapter

PhotoAdapter adapter = new PhotoAdapter(this, imageNameList, thumbURLList); listPhoto.setAdapter(adapter); //listPhoto is my listView

(photolist.xml)

android:id="@+id/lblAlbumName" android:layout_width="fill_parent" android:layout_height="wrap_content" />

(photoitemlist.xml)

please help..

thanks...