如何在Spinner中爲以下一堆代碼設置適配器?我應該將適配器下Spinner中的適配器,Android
//一套適配器微調這裏
public class ListViewFragment extends Fragment implements OnItemSelectedListener{
public ListViewFragment(){}
Spinner mspinner; //declare spinner globally
ArrayAdapter<String> adapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_listview, container, false);
mspinner = (Spinner) view.findViewById(R.id.spinner1);
//set adapter for spinner here
return rootView;
}
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position,
long id) {
//do something when particular item is selected from spinner
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
}
}
你想要做這樣的?請參閱http://mrbool.com/how-to-customize-spinner-in-android/28286 – User11
@ R.T。 其實我不知道如何設置適配器。我不需要定製。 –
這個例子是爲了定製微調,你看到了嗎? – User11