Adapter won't run on a real device
<p>The same code that displays the lists running on the emulator doesn't run on the mobile (Motorola Milestone). I'm using the same android platform (2.1-update).</p>

<h2>Inbox Code</h2>

<pre><code>private ArrayList&lt;EmailModel&gt; email_list;


private EmailAdapter email_adapter;

 @Override
 public void onCreate(Bundle savedInstanceState) {

  super.onCreate(savedInstanceState);

  try {
   this.email_list = populate_list();
   email_adapter = new EmailAdapter(this, email_list);
   setListAdapter(email_adapter);

  } catch (Exception e) {
   Log.v("Inbox", "Adapting Problem: " + e.toString());
  }
 }
</code></pre>

<h2>EmailAdapter Code</h2>

<pre><code>public class EmailAdapter extends BaseAdapter {



private ArrayList&lt;EmailModel&gt; elements;
private Context c;

public EmailAdapter(Context c, ArrayList&lt;EmailModel&gt; Emails) {

 this.elements = Emails;
    this.c = c;
}
public int getCount() {

    return elements.size();
}

public Object getItem(int position) {

    return elements.get(position);
}

public long getItemId(int id) {

    return id;
}

public void Remove(int id) {
    notifyDataSetChanged();
}

public void Add(EmailModel email) {

 this.elements.add(email);

 notifyDataSetChanged();
}

public View getView(int position, View convertView, ViewGroup parent) {

    LinearLayout rowLayout;
    EmailModel email = elements.get(position);

    if (convertView == null) {
     rowLayout = (LinearLayout) LayoutInflater.from(c).inflate(R.layout.inbox_item, parent, false); 
    } else {
        rowLayout = (LinearLayout) convertView;
    }

 TextView subject_textview = (TextView)rowLayout.findViewById(R.id.subject_textview);
 subject_textview.setText(email.getSubject());

 String body_hint = " - " + email.getBodyHint();

 TextView bodyhint_textview = (TextView)rowLayout.findViewById(R.id.body_hint_textview);
 bodyhint_textview.setText(body_hint);


 String sender_name = get_sender_name(email.getSender());

 TextView sender_name_textview = (TextView)rowLayout.findViewById(R.id.sender_textview);
 sender_name_textview.setText(sender_name);

 TextView date_time_textview = (TextView)rowLayout.findViewById(R.id.date_time_textview); 
 date_time_textview.setText(email.getTime());


    return rowLayout;
}

private String get_sender_name(String from) {

 String[] sender = from.split("&lt;");


String sender_name;

  try {
   sender_name = sender[0];
  } catch (Exception e) {
   sender_name = sender[1];
  }
  return sender_name;
    }}
</code></pre>

<h2>exception output</h2>

<blockquote>
  <p>07-16 13:15:21.190: VERBOSE/Inbox(429): Adapting Problem: java.lang.ArrayIndexOutOfBoundsException</p>
</blockquote>

<h2>Stack Trace</h2>

<blockquote>
  <p>07-16 14:00:49.690: WARN/System.err(703): java.lang.ArrayIndexOutOfBoundsException
  07-16 14:00:49.698: WARN/System.err(703):     at com.anubis.mail.Inbox.populate_list(Inbox.java:237)
  07-16 14:00:49.698: WARN/System.err(703):     at com.anubis.mail.Inbox.onCreate(Inbox.java:69)
  07-16 14:00:49.698: WARN/System.err(703):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
  07-16 14:00:49.698: WARN/System.err(703):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
  07-16 14:00:49.706: WARN/System.err(703):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
  07-16 14:00:49.706: WARN/System.err(703):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
  07-16 14:00:49.706: WARN/System.err(703):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
  07-16 14:00:49.706: WARN/System.err(703):     at android.os.Handler.dispatchMessage(Handler.java:99)
  07-16 14:00:49.706: WARN/System.err(703):     at android.os.Looper.loop(Looper.java:123)
  07-16 14:00:49.706: WARN/System.err(703):     at android.app.ActivityThread.main(ActivityThread.java:4363)
  07-16 14:00:49.706: WARN/System.err(703):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-16 14:00:49.706: WARN/System.err(703):     at java.lang.reflect.Method.invoke(Method.java:521)
  07-16 14:00:49.706: WARN/System.err(703):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
  07-16 14:00:49.706: WARN/System.err(703):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
  07-16 14:00:49.706: WARN/System.err(703):     at dalvik.system.NativeStart.main(Native Method)</p>
</blockquote>
