我正在获取我的Gmail帐户的收件箱文件夹,可以列出传入的电子邮件,但该列表正在从旧邮件列表到新邮件。我怎样才能恢复呢?
public class readInbox extends ListActivity{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
//setContentView(R.layout.readmail);
Message[] messages = new Message[] { };
try {
messages = inboxReader.getMail();
}
catch (MessagingException e) {
Log.e("mailReader getMail error. in readmail.java", e.getMessage(), e);
}
ArrayAdapter<Message> adapter = new ArrayAdapter<Message>(this,
R.layout.simple_list_item_1 ,messages){
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Message message = getItem(position);
TextView resultView = new TextView(super.getContext());
try {
resultView.setText(message.getSubject());
}
catch (MessagingException e) {
Log.e("resultView.setText in readmail", e.getMessage(), e);
}
return resultView;
}
};
setListAdapter(adapter);
}
}
答案 0 :(得分:0)
要么颠倒数组的顺序,要么对getItem
,使用恢复的索引(count-position-1)。
有关listView的更多信息,请查看此视频:
http://www.google.com/events/io/2010/sessions/world-of-listview-android.html
答案 1 :(得分:0)
您可以通过inbox.getMessageCount()
获取邮件总数,然后检索最后N个邮件数。
Message messages[] = inbox.getMessages(inbox.getMessageCount() - 25 , inbox.getMessageCount());