我正在开发安卓应用程序。在我的具有两个活动的应用程序中,第一个活动显示列表,第二个活动在同一活动中具有微调器和列表视图,当用户单击微调器中的项目时,将显示列表视图。当用户从第一个活动导航到第二个活动时,微调器会正确填充列表视图。但问题是列表视图正确显示后,微调项为空白。我不知道我在哪里做错了。请任何人有解决方案。
在这里,我发布了第二个活动的一些代码
public class ProjectDetailActivity extends SherlockListActivity {
private List<String> list = new ArrayList<String>();
private ArrayList<HashMap<String, String>> list2 = new ArrayList<HashMap<String,String>>();
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_project_detail);
//get spinner item from server when user comes from first activity.
new LoadPhaseData().execute();
//Listener for Phase spinner
projSpinnerPhase.setOnItemSelectedListener((OnItemSelectedListener) new OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View arg1,
int arg2, long arg3) {
//get listview when user click item from spinner
new LoadPhaseData().execute();
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
});
//this adapter for listview when click item from spinner
ListAdapter phaseAdapter = new SimpleAdapter(getApplicationContext(),
list2, R.layout.phase_avail_list_item,
new String[] {PHASE_NAME}, new int[]
{R.id.phaseName});
setListAdapter(phaseAdapter);
}
private class LoadPhaseData extends AsyncTask<String, Void, Void> {
@Override
protected Void doInBackground(String... params) {
//Here I am calling web service for spinner and listview
}
@Override
protected void onPostExecute(Void result) {
//following adapter for spinner item
ArrayAdapter<String> dataAdapter = new ArrayAdapter<String>(
getApplicationContext(),android.R.layout.simple_spinner_item,list);
dataAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
projSpinnerPhase.setAdapter(dataAdapter);
}
}
}
提前致谢