title: how to change background color of specific list items
body: <p>In following code I have added sent and received messages in a list.Now i want to show them in listview in such a way that sent messages must be with different background color and received messages with different background color anybody help.</p>
  
  <pre><code>            public List&lt;String&gt; getSMS() {
  
      List&lt;String&gt; sms1 = new ArrayList&lt;String&gt;();
      List&lt;String&gt; sms = new ArrayList&lt;String&gt;();
      sms2 = new ArrayList&lt;String&gt;();
      Uri uriSMSURI = Uri.parse("content://sms/");
     // Uri uriSMSURI1 = Uri.parse("content://sms/inbox");
      Cursor cur = getContentResolver().query(uriSMSURI, null, null, null,null);
      //Cursor cur1 = getContentResolver().query(uriSMSURI1, null, null, null,null);
      while (cur.moveToNext()) {
          int type = cur.getColumnIndex("type");
          String address = cur.getString(cur.getColumnIndex("address"));
          long  millis = cur.getLong(cur.getColumnIndexOrThrow("date"));
          String dat = (String) DateFormat.format("EEEE, MMMM dd, yyyy h:mm:ss aa", new Date(millis));
          String body = cur.getString(cur.getColumnIndexOrThrow("body"));
          int z=address.length();
  
          if (z==13)
          {
              address=address.substring(3, 13);
              address="0" + address;
              address = address.toString();
  
          }
  
          if (address.equals(str))
          {
              if(cur.getString(type).equalsIgnoreCase("1")){
                  // sms received
  
  
                  sms.add("Received: " + body + "\n" + dat);
               }
               else if(cur.getString(type).equalsIgnoreCase("2")){
                  //sms sent
                   sms.add(" Sent: " + body + "\n" + dat);
               }
           }
  }
      return sms;
  }
  </code></pre>