我使用自定义ListView,其中包含textview,两个微调器。另一个微调器基于listview中的微调器选择项构建。请在android中给出一个示例。 如何根据第一个微调器的选定项目来创建来自数据库的动态微调器请告诉......
@Override
public View getView(final int position, View convertView,
ViewGroup parent) {
LayoutInflater layoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = layoutInflater.inflate(R.layout.previousrolelist,null);
ob = previousErollment.get(position);
holder.selectlevelID = (Spinner) convertView.findViewById(R.id.selectlevelID);
holder.partyDesignationID = (Spinner)convertView.findViewById(R.id.partyDesignationIDs);
holder.cadreCommiteeId=(Spinner) convertView.findViewById(R.id.cadreCommitee);
// holder.samplespin=(Spinner)convertView.findViewById(R.id.samplespinID);
holder.fromdateeditID = (TextView) convertView.findViewById(R.id.fromdateeditID);
holder.todateeditID = (TextView) convertView.findViewById(R.id.todateeditID);
deleteID = (ImageView) convertView.findViewById(R.id.deleteID);
fromDate = ob.getFromDate();
toDate = ob.getToDate();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.customspinner, selectionLevel);
holder.selectlevelID.setAdapter(adapter);
holder.selectlevelID.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3)
{
spinner1.put(position, arg2);
ob.SelectionLevelId(spinner1.get(position));
Log.e("level position", "pos"+position+"arg2"+arg2);
ArrayAdapter<String> cadreroleadapter = new ArrayAdapter<String>(getApplicationContext(),R.layout.customspinner, cadreCommittee);
holder.cadreCommiteeId.setAdapter(cadreroleadapter);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
holder.cadreCommiteeId.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3) {
// TODO Auto-generated method stub
cadrespinner.put(position, arg2);
ob.setCommitte(cadrespinner.get(position));
Log.e("level position", "pos"+position+"arg2"+arg2);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(getApplicationContext(),R.layout.customspinner, party_designation);
holder.DesignationID.setAdapter(adapter1);
holder.DesignationID.setOnItemSelectedListener(new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,int arg2, long arg3)
{
spinner2.put(position, arg2);
ob.setLevelId(spinner2.get(position));
Log.e("level position", "pos"+position+"arg2"+arg2);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
});
if (spinner1.get(position) != null)
{
holder.selectlevelID.setSelection(spinner1.get(position));
}
if (spinner2.get(position) != null)
{
holder.partyDesignationID.setSelection(spinner2.get(position));
}
if(cadrespinner.get(position)!=null)
{
holder.cadreCommiteeId.setSelection(cadrespinner.get(position));
}
if (from.get(position) != null)
{
holder.fromdateeditID.setText(fromDate);
}
if (to.get(position) != null)
{
holder.todateeditID.setText(toDate);
}
return convertView;
}
}