package com.sogouchat.popnewmsg;
import java.util.Vector;
import android.content.Context;
import android.graphics.Color;
import android.text.format.Time;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
public class PopSubListAdapter extends BaseAdapter {
private Context context;
private Vector<PopMessage> messages;
public PopSubListAdapter(Vector<PopMessage> mVector,Context context){
messages = mVector;
this.context = context;
}
public int getCount() {
// TODO Auto-generated method stub
return messages.size();
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return messages.get(position);
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
PopMessage popMessage = (PopMessage)getItem(position);
if (popMessage!=null) {
LinearLayout layout = new LinearLayout(context);
layout.setOrientation(LinearLayout.VERTICAL);
TextView textBody = new TextView(context);
textBody.setText(popMessage.strBody);
textBody.setGravity(Gravity.LEFT);
TextView textDate = new TextView(context);
textBody.setTextColor(Color.BLACK);
Time tm = new Time();
tm.set(popMessage.tm);
textDate.setText(tm.format("%H:%M"));
textDate.setGravity(Gravity.LEFT);
layout.addView(textBody);
layout.addView(textDate);
return layout;
}
return null;
}
}