我在Activity
类中创建了一些片段,作为标签,您可以在其中切换,在其中我有各种Spinner
。我从JSONParser
和Spinner
获取的数据来自fragment
类,如下所示:
spinnerMaterial = (Spinner) view.findViewById(R.id.Spinner_material);
List<String> lables_material = new ArrayList<String>();
for (int i = 0; i < materialList.size(); i++) {
lables_material.add(materialList.get(i).getMaterial());
}
// Creating adapter for spinner
ArrayAdapter<String> spinnerAdapter_material = new ArrayAdapter<String>(getActivity(),
android.R.layout.simple_spinner_item, lables_material);
// Drop down layout style - list view with radio button
spinnerAdapter_material
.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
// attaching data adapter to spinner
spinnerMaterial.setAdapter(spinnerAdapter_material);
// spinner item select listener
spinnerMaterial.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view,
int position, long id) {
Object item = adapterView.getItemAtPosition(position);
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// TODO Auto-generated method stub
}
});
&#13;
实际上一切正常。我收到了所有数据,Spinner
正在弹出。但不是直接的方式。所以我需要在标签(fragments
)之间切换,然后返回Spinner
显示数据。奇怪的是,当我尝试调试并查看某些breakpoints
时,Spinner
会立即弹出(不切换标签页)。
你知道问题可能是什么吗?