如果事件生成到相应的微调器中,我想显示数据库中的数据。每件事都在推进。但是第三个微调器的问题...第三个微调器没有使用spinnerOne的第二个值正确更新。(第一个和第二个微调器没有问题)
我试过的代码..
//-----1st spinner is working fine------(Problem only with 3rd spinner ita not updating properly)//
//------for storing data into second spinner----//
SpinnerOne.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
{
myDataBase.openDB();
AdapterTwo.clear();
long idi = id+1;
Cursor cursor = myDataBase.getSecondDetails();
if(cursor != null && cursor.getCount()>0)
{
cursor.moveToFirst();
do
{
long id1 = cursor.getLong(2);
if(id1 == idi)
{
AdapterTwo.add(cursor.getString(1));
AdapterTwo.notifyDataSetChanged();
//SpinnerTwo.setAdapter(AdapterTwo);
}
}
while(cursor.moveToNext());
}
SpinnerTwo.setAdapter(AdapterTwo);
myDataBase.close();
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
//----------for storing data into third spinner-------//
final ArrayAdapter<String> AdapterTrhee = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item);
SpinnerTwo.setOnItemSelectedListener(new OnItemSelectedListener()
{
@Override
public void onItemSelected(AdapterView<?> parent, View view, int pos, long id)
{
myDataBase.openDB();
AdapterThree.clear();
long id1 = id+1;
Cursor cursor = myDataBase.getThirdDetails();
if(cursor != null && cursor.getCount()>0)
{
cursor.moveToFirst();
do
{
long id2 = cursor.getLong(2);
if(id1 == id2)
{
AdapterThree.add(cursor.getString(1));
AdapterThree.notifyDataSetChanged();
//SpinnerThree.setAdapter(cityAdapter);
}
}
while(cityCursor.moveToNext());
}
SpinnerThree.setAdapter(cityAdapter);
myDataBase.closeDB();
}
@Override
public void onNothingSelected(AdapterView<?> parent)
{
}
});
我使用Data Base检查过一切正常。查询和所有其他内容都是正确的。
第三个微调器也正常工作,第一个微调器的第一个值,但如果我改变第一个微调器的值,第三个微调器显示不正确的数据。(第二个微调器工作正常)