views:

92

answers:

1
public class List_View extends ListActivity {

    private TextView toptext; 
    private TextView bottomtext;

    DBAdapter db = new DBAdapter(this);

    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        setContentView(R.layout.list);
        getData();

        toptext = (TextView) findViewById(R.id.toptext); 
        bottomtext = (TextView) findViewById(R.id.bottomtext); 

    }

    private void getData() {            
           db.open();

           Cursor c = db.getAllEntry();
           c.moveToFirst(); 

           ListAdapter adapter = new SimpleCursorAdapter(this,R.layout.view_list, c, new String[] {"date", "title"}, new int[] {R.id.toptext, R.id.bottomtext});

           bottomtext.setText(c.getString(1)); 
           toptext.setText(c.getString(4)); 

           setListAdapter(adapter);

           db.close(); 
    }

}

I would like to show stored data from database into a ListView.

Title and Date only.

A: 

Just glancing over it; your call to getData lies before toptext and bottomtext is set.

alexanderblom