mercredi 28 octobre 2015

How to display the data retrieved from the database in checkbox

Hello im new in android programming, i am having a hard time on how will i display multiple data that was retrieve from the database and put it in a checkbox.

Here is my code:

public class TemplateActivity extends Activity {

TextView optValidity;
TextView optName;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_template);

    optName = (TextView) findViewById(R.id.optName);
    optValidity = (TextView) findViewById(R.id.optNumber);

    RetailerDatabaseHelper dbHelper = new RetailerDatabaseHelper(this);
    dbHelper.retrieveData();

    Cursor AllData = dbHelper.getData();
    AllData.moveToFirst();

    while (!AllData.isAfterLast())
    {
        String Name = AllData.getString(AllData.getColumnIndex("name"));
        String validity = AllData.getString(AllData.getColumnIndex("validity"));

        optName.append(Name + " " + validity + "\n");

        AllData.moveToNext();
    }
}

Aucun commentaire:

Enregistrer un commentaire