Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- protected void onCreate(Bundle savedInstanceState) {
- // TODO Auto-generated method stub
- super.onCreate(savedInstanceState);
- setContentView(R.layout.timeline);
- //capture view elements
- ListView months=(ListView)findViewById(R.id.months);
- db=new Database(this);
- cursor=db.getAll();
- startManagingCursor(cursor);
- adapter=new DiaryAdapter(cursor);
- months.setAdapter(adapter);
- }
- class DiaryAdapter extends CursorAdapter {
- //constructor
- DiaryAdapter(Cursor c) {
- super(Timeline.this, c);
- }
- @Override
- public void bindView(View row, Context ctxt,Cursor c) {
- DiaryHolder holder=(DiaryHolder)row.getTag();
- holder.populateFrom(c, db);
- }
- @Override
- public View newView(Context ctxt, Cursor c,ViewGroup parent) {
- LayoutInflater inflater=getLayoutInflater();
- View row=inflater.inflate(R.drawable.row, parent, false);
- DiaryHolder holder=new DiaryHolder(row);
- row.setTag(holder);
- return(row);
- }
- }//end of DiaryAdapter
- tatic class DiaryHolder {
- private TextView title=null;
- private TextView time=null;
- DiaryHolder(View row) {
- title=(TextView)row.findViewById(R.id.title);
- time=(TextView)row.findViewById(R.id.time);
- }
- void populateFrom(Cursor c, Database helper) {
- time.setText(helper.getTime(c));
- title.setText(helper.getDay(c));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement