Advertisement
ChocoMan

Untitled

Jun 9th, 2012
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. @Override
  2.     public View getView(final int position, View convertView, ViewGroup parent) {
  3.         View rowView = convertView;
  4.         final ViewHolder holder;
  5.         if (rowView == null) {
  6.             ....
  7.             ....
  8.             ....
  9.         // RETRIEVE LATEST SMS FROM CONTACTS WHO SENT SMS
  10.             String folder = "content://sms/inbox/";
  11.             Uri mSmsQueryUri = Uri.parse(folder);
  12.             messages = new ArrayList<String>();
  13.             contactID = new ArrayList<String>();
  14.  
  15.             try {
  16.                 c = context.getContentResolver().query(mSmsQueryUri,
  17.                         new String[] { "_id", "address", "date", "body" },
  18.                         null, null, null);
  19.                 if (c == null) {
  20.                     Log.i(TAG, "cursor is null. uri: " + mSmsQueryUri);
  21.                 }
  22.  
  23.                 c.moveToFirst();
  24.                 while (c.moveToNext()) {
  25.  
  26.                     body = c.getString(3);
  27.                     phoneNumber = c.getString(1);
  28.                     contactID.add(phoneNumber + "\n" + " " + body);
  29.                 }
  30.  
  31.                 c.moveToFirst();
  32.                 while (c.moveToNext()) {
  33.  
  34.                     body = c.getString(3);
  35.                     phoneNumber = c.getString(1);
  36.                     messages.add(phoneNumber + " " + body);
  37.                 }
  38.             } catch (Exception e) {
  39.                 Log.e(TAG, e.getMessage());
  40.             } finally {
  41.                 c.close();
  42.             }
  43.  
  44.     holder.latestSMS.setText(messages.get(position); // Display text message segment
  45.  
  46.         } else {
  47.             holder = (ViewHolder) rowView.getTag();
  48.         }
  49.  
  50.     if (holder != null) {
  51.  
  52.             // bind the data to the row views
  53.             String testing = contactNo.get(position); // Display phone number
  54.     }
  55. } // end getView
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement