Reputation: 41
I am a new programmer. I am unable to give a start for this. I would like to populate cFloors to a list.
Thankyou in advance...
public class FloorsActivity extends Activity {
AutomationDBAccessor db = new AutomationDBAccessor(this);
private OnClickListener floorsUpdateListener = new OnClickListener(){
public void onClick(View v) {
// TODO Auto-generated method stub
Cursor cFloors = db.getFloors();
if(cFloors!=null)
{
Toast toast = Toast.makeText(getApplicationContext(), "floors loaded", Toast.LENGTH_SHORT);
toast.show();
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.floors);
Button btnGetFloors = (Button) findViewById(R.id.btnGetFloors);
btnGetFloors.setOnClickListener(floorsUpdateListener);
}
}
Upvotes: 0
Views: 486
Reputation: 1934
you can follow the link http://android-support-akkilis.blogspot.com/2011/11/simple-cursor-adapter-made-easy.html.
It contains all the data/code you require to build a simple cursor adapter.
Upvotes: 0
Reputation: 5372
Have a look at this example on using a ListView: http://developer.android.com/resources/tutorials/views/hello-listview.html
But instead of ArrayAdapter in the example, you can use a SimpleCursorAdapter for cFloors and attach it to the view using setListViewAdapter().
SimpleCursorAdapter: http://developer.android.com/reference/android/widget/SimpleCursorAdapter.html
Upvotes: 1