我正在尝试使用Volley POST请求的结果填充一个微调器,并使此功能正常工作。微调器填充在线数据库中的结果。但是,尽管每次打开时项目都在微调器内显示,但无法访问所选项目。
返回错误消息:
W/InputEventReceiver: Attempted to finish an input event but the input event receiver has already been disposed.
旋转器上方的方法调用将所有的截击响应输入到可用的时间数组中。这是我的onCreateView中的代码(微调器在一个片段中):
//method call to send Volley request for available date and time and add to arraylist
populateAvailSlots(user_id);
// you can use this array to populate your spinner
spWhenChoice = (Spinner) view.findViewById(R.id.spWhenChoice);
ArrayAdapter<String> whenAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, availSlots.getAList());
whenAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spWhenChoice.setAdapter(whenAdapter);
spWhenChoice.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapter, View v,
int position, long id) {
// On selecting a spinner item
String timeSelected = spWhenChoice.getItemAtPosition(position).toString();
System.out.println(timeSelected);
spinBundle.putString("timeSelected", timeSelected);
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
//empty string
}
});
一旦选择了该项目,我就会尝试存储它的文本并将其传递给buttonclick上的片段:
btnStudBook = (Button) view.findViewById(R.id.btnStudBook);
btnStudBook.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (spinBundle.isEmpty()) {
//inform the user that they need to select from spinner
Toast.makeText(getActivity(), "Please select a time",
Toast.LENGTH_SHORT).show();
} else {
//create an object of the class to navigate to
StudAppointInput fragment = new StudAppointInput();
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.replace(R.id.studBaseLayout, fragment);
//add back button functionality
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
fragment.setArguments(spinBundle);
}
}
});