Don't like ads? PRO users don't see any ads ;-)
Guest

CloudSyncActivity.java Listadapter code

By: holyvincent on Aug 10th, 2012  |  syntax: None  |  size: 1.16 KB  |  hits: 7  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //Initializing the list-view
  2.         ListView listView = (ListView) findViewById(R.id.time_list);
  3.            // Taking the time value
  4.         timeCur = getContentResolver().query(CloudSyncContentProvider.TIME_CONTENT_URI, null, null, null, null);
  5.         timeCur.moveToFirst();
  6.         int timeLen = timeCur.getCount();
  7.         String[] timeArr = new String[timeLen];
  8.         for(int i =0;i<timeCur.getCount();i++) {
  9.                 timeArr[i] = timeCur.getString(1);
  10.                 timeCur.moveToNext();
  11.         }
  12.         String[] demo_value = new String[] { "Android", "iOS", "WindowsMobile",
  13.                                 "Blackberry", "Android", "iOS", "WindowsMobile", "Blackberry" };
  14.         Ulg.d("the lenght of timeArr is:=> "+timeArr.length);
  15.        
  16.         String[] val = new String[5];
  17.         String[] parVal;
  18.                 if(timeArr.length < 5) {
  19.                         for (int i = 0; i < timeArr.length; i++) {
  20.                                 val[i] = timeArr[i];
  21.                         }
  22.                         for(int i = timeArr.length;i<5;i++) {
  23.                                 val[i] = "noval";
  24.                         }
  25.                         parVal = val;
  26.                 } else {
  27.                         parVal = timeArr;
  28.                 }
  29.         SyncTimeArrayAdapter staAdapt = new SyncTimeArrayAdapter(this, parVal);
  30.         listView.setAdapter(staAdapt);
  31.         timeCur.close();