title: Dynamic creation of list view dosen't show multiple rows in android
body: <p>Being a newbie to android I am trying to implement List view on my project. The list view works. However I am only able to see one row in my list. I wish to add as many rows as I want dynamically.
  I have created a separate XML which defines the structure of a single row in the list view.
  Here is what I have coded until now :</p>
  
  <pre><code>public class Offers extends Activity 
  {
      ListView latesttrans;
  
      ArrayList&lt;String&gt; listItems = new ArrayList&lt;String&gt;();
      @Override
      protected void onCreate(Bundle savedInstanceState) 
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_offers);
          latesttrans = (ListView) findViewById(R.id.listView1);
          latesttrans.setAdapter(new mylist2(this));
      }
  }
      class SingleRow2
      {
          String title;
          String description;
          SingleRow2(String title, String description)
          {
              this.title=title;
              this.description=description;
          }
      }
      class mylist2 extends BaseAdapter
      {
          int i=0;
          Boolean flagValue = false;
          ArrayList&lt;SingleRow&gt; list;
          Context context;
          mylist2(Context c)
          {
              context=c;
              list=new ArrayList&lt;SingleRow&gt;();
              Resources res = c.getResources();
              String[] title = res.getStringArray(R.array.titles);
              String[] description = res.getStringArray(R.array.description);
  
                  list.add(new SingleRow(title[i],description[i]));
                  i++;
          }
  
          @Override
          public int getCount() 
          {
              // TODO Auto-generated method stub
              return list.size();
          }
  
          @Override
          public Object getItem(int arg0) 
          {
              // TODO Auto-generated method stub
              return list.get(arg0);
          }
  
          @Override
          public long getItemId(int arg0) 
          {
              // TODO Auto-generated method stub
              return arg0;
          }
  
          @Override
          public View getView(int arg0, View arg1, ViewGroup viewGroup) 
          {
              // TODO Auto-generated method stub
              LayoutInflater inflater= (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
              View row = inflater.inflate(R.layout.single_row_offers,viewGroup,false);
  
              Uri latesttransuri = Uri.parse("content://sms/inbox");
              Cursor latesttranscursor = context.getContentResolver().query(latesttransuri, new String[]{"_id","address","date","body"}, null, null, null);
  
              if(flagValue == false)
              {
                  latesttranscursor.moveToFirst();
                  flagValue = true;
              }
  
              String address = null,body = null;
              int i=0;
  
                  while(latesttranscursor.moveToNext())
                  {
                      address=latesttranscursor.getString(1);
                      long date = latesttranscursor.getLong(2);
                      String sdate = millisToDate(date);
                      body = latesttranscursor.getString(3);
  
                      if(body.contains("FREE"))
                      {
                          TextView title = (TextView) row.findViewById(R.id.textViewSingleOffer1);
                          TextView description = (TextView) row.findViewById(R.id.textViewSingleOffer2);
                          title.setText(address);
                          description.setText(body);
                      }
                      else if(body.contains("unlimited"))
                      {
                          TextView title = (TextView) row.findViewById(R.id.textViewSingleOffer1);
                          TextView description = (TextView) row.findViewById(R.id.textViewSingleOffer2);
                          title.setText(address);
                          description.setText(body);
                      }
  
                  }
  
              return row;
          }
          public String millisToDate(long currentTime) 
          {
              String finalDate;
              Calendar calendar = Calendar.getInstance();
              calendar.setTimeInMillis(currentTime);
              Date date = calendar.getTime();
              finalDate = date.toString();
              return finalDate;
          }
  
      }
  </code></pre>