Hi I am new to this android. I am just confused by base adapter. My problem is that consider In an array I have 10 items(from 0 to 9). In the getview() option of baseadapter I am displaying this in textview. But after executing 5 times correctly once again the position is resetting to 0. So items are repeating twice.
This is my adapterclass:
public class ListViewwithimageAdapter extends BaseAdapter
{
    private static Context contxt;
    final String URL = "http://xxxx.in/SSDAA.xml";
    final String[] kickerimage = new String[150];
    ListViewwithimageAdapter(Context conxt)
    {
//      System.out.println("inside cons");
        this.contxt=conxt;
    }
    {
    }
    public String[] getelement()
    {
//      System.out.println("Insid getelement");
         ArrayList<String> menuItems = new ArrayList<String>();
          TaplistingParser parser = new TaplistingParser();
          String xml= parser.getXmlFromUrl(URL);
          Document doc=parser.getDomElement(xml);        
//        System.out.println("sssss="+doc);
          NodeList nl=doc.getElementsByTagName("article");
          final String[] url= new String[nl.getLength()];
//        String headings = null;
          for(int i=0; i < nl.getLength(); i++ )
          {
//            System.out.println("i="+i);
            HashMap<String, String> map = new HashMap<String, String>();
            Element e = (Element) nl.item(i);
//          map.put("Title", parser.getValue(e, "title"));
//          map.put("Date", parser.getValue(e, "create_date"));         
            url[i]=parser.getValue(e, "url");
//          System.out.println("b4 kick");
//          System.out.println("value="+parser.getValue(e, "title"));
            kickerimage[i]=parser.getValue(e, "kickerimage");
//          System.out.println("after kick");
//          System.out.println("kick="+kickerimage[i]);
            menuItems.add(parser.getValue(e, "title"));          
          }  
//         System.out.println("b4 items array");
           String[] itemsarray = new String[menuItems.size()];
//         System.out.println("subbu");
           itemsarray=menuItems.toArray(itemsarray);
//         System.out.println("subbu1");
//         System.out.println("in last");
           return itemsarray;
    }
    @Override
    public int getCount() {
        // TODO Auto-generated method stub
        return getelement().length;
    }
    @Override
    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return getelement()[position];
    }
    @Override
    public long getItemId(int position) {
        // TODO Auto-generated method stub
//      System.out.println("pos in id="+position);
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) 
    {
        // TODO Auto-generated method stub
        System.out.println("pos in id="+position);                     ------------------->This soutline gives output as(0,1,2,3,4,5,0).
         Bitmap bitmap = DownloadImage(
                 kickerimage[position] );
        LayoutInflater inflater = (LayoutInflater) contxt
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View listView;
        if (convertView == null) 
        {
            listView = new View(contxt);             
            listView = inflater.inflate(R.layout.homelistrow, null); 
            System.out.println("pos="+position);
            System.out.println("item="+getItem(position));
            TextView textView = (TextView) listView
                    .findViewById(R.id.name_label);
            textView.setText(getelement()[position]);
            ImageView imageView = (ImageView) listView
                    .findViewById(R.id.icon);
            imageView.setImageBitmap(bitmap);
        }
        else        
        {
            listView = (View) convertView;
        } 
        return listView;
    }
    private Bitmap DownloadImage(String URL)
    {        
//      System.out.println("image inside="+URL);
        Bitmap bitmap = null;
        InputStream in = null;        
        try {
            in = OpenHttpConnection(URL);
            bitmap = BitmapFactory.decodeStream(in);
            in.close();
        } catch (IOException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
        }
//        System.out.println("image last");
        return bitmap;                
    }
    private InputStream OpenHttpConnection(String urlString)
            throws IOException
            {
                InputStream in = null;
                int response = -1;
                URL url = new URL(urlString);
                URLConnection conn = url.openConnection();
                if (!(conn instanceof HttpURLConnection))                    
                    throw new IOException("Not an HTTP connection");
                try{
                    HttpURLConnection httpConn = (HttpURLConnection) conn;
                    httpConn.setAllowUserInteraction(false);
                    httpConn.setInstanceFollowRedirects(true);
                    httpConn.setRequestMethod("GET");
                    httpConn.connect();
                    response = httpConn.getResponseCode();                
                    if (response == HttpURLConnection.HTTP_OK) {
                        in = httpConn.getInputStream();                                
                    }                    
                }
                catch (Exception ex)
                {
                    throw new IOException("Error connecting");            
                }
                return in;    
    }
}
My Homerowlist:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
    <ImageView
        android:id="@+id/icon"
        android:layout_width="80dp"
        android:layout_height="80dp"        
        android:paddingLeft="10dp"
        android:paddingRight="10dp" />
    <TextView
        android:id="@+id/name_label"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toRightOf="@+id/icon"
        android:paddingBottom="10dp"
        android:textColor="#ffffff"
        android:textSize="16dp" />
</RelativeLayout>
In my activity setting adapter:
 ListView l2= (ListView)findViewById(R.id.list);
          ListViewwithimageAdapter adapter = new ListViewwithimageAdapter(this);
          l2.setAdapter(adapter);
Please help me. Thanks in advance.
 
     
    