Я хочу заполнить текстовые представления данными из SQLite в своей деятельности, когда я выбираю элемент в счетчике.
Не отображается ошибка, но текстовые представления также не заполняются.
активность
rate_type_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l)
{
switch(i) {
case 0:
ResidentialRate();
break;
case 1:
break;
default:
break;
}
}
@Override
public void onNothingSelected(AdapterView<?> adapterView)
{
}
});
}
public void ResidentialRate()
{
db = new DatabaseHelper(getApplicationContext());
sqLiteDatabase = db.getReadableDatabase();
Cursor cursor = db.ResidentialListDetails();
if (cursor.moveToFirst()) {
do {
String GENERAL_SYSTEM_CHARGE = cursor.getString(1);
String FRANC_BENEFIT_TO_HOST_COMM = cursor.getString(2);
String TRANSMISSION_SYSTEM_CHARGE = cursor.getString(3);
String TRANSMISSION_DEMAND_CHARGE = cursor.getString(4);
String SYSTEM_LOSS_CHARGE = cursor.getString(5);
String DISTRIBUTION_DEMAND_CHARGE = cursor.getString(6);
String DISTRIBUTION_SYSTEM_CHARGE = cursor.getString(7);
gen_system_charge.setText(GENERAL_SYSTEM_CHARGE);
franc_benefit_to_host_comm.setText(FRANC_BENEFIT_TO_HOST_COMM);
trans_system_chg.setText(TRANSMISSION_SYSTEM_CHARGE);
trans_demand_chg.setText(TRANSMISSION_DEMAND_CHARGE);
system_loss_chg.setText(SYSTEM_LOSS_CHARGE);
distr_demand_chg.setText(DISTRIBUTION_DEMAND_CHARGE);
distr_system_chg.setText(DISTRIBUTION_SYSTEM_CHARGE);
}
while (cursor.moveToNext());
}
}
класс для выбора данных
public class RateListTypeDetails
{
public static abstract class rateListValues
{
public static final String TABLE_NAME = "Rate";
public static final String RATE_TYPE = "type";
public static final String GENERAL_SYSTEM_CHARGE = "gen_system_charge";
public static final String FRANC_BENEFIT_TO_HOST_COMM = "franc_benefit_to_host_comm";
public static final String TRANSMISSION_SYSTEM_CHARGE = "trans_system_chg";
public static final String TRANSMISSION_DEMAND_CHARGE = "trans_demand_chg";
public static final String SYSTEM_LOSS_CHARGE = "system_loss_chg";
public static final String DISTRIBUTION_DEMAND_CHARGE = "distr_demand_chg";
public static final String DISTRIBUTION_SYSTEM_CHARGE = "distr_system_chg";
}
}
Помощник БД
public Cursor ResidentialListDetails()
{
SQLiteDatabase sqLiteDatabase = this.getReadableDatabase();
String [] projections = {RateListTypeDetails.rateListValues.GENERAL_SYSTEM_CHARGE,
RateListTypeDetails.rateListValues.FRANC_BENEFIT_TO_HOST_COMM,
RateListTypeDetails.rateListValues.TRANSMISSION_SYSTEM_CHARGE,
RateListTypeDetails.rateListValues.TRANSMISSION_DEMAND_CHARGE,
RateListTypeDetails.rateListValues.SYSTEM_LOSS_CHARGE,
RateListTypeDetails.rateListValues.DISTRIBUTION_DEMAND_CHARGE,
RateListTypeDetails.rateListValues.DISTRIBUTION_SYSTEM_CHARGE,
String selection = RateListTypeDetails.rateListValues.RATE_TYPE+" LIKE ?";
Cursor cursor = sqLiteDatabase.query(RateListTypeDetails.rateListValues.TABLE_NAME,projections, selection, null,null,null,null);
return cursor;
}
Я хочу, чтобы эти текстовые представления с подсказками заполнялись данными sqlite с использованием счетчика
Заранее спасибо.