嗨,我正在使用ArrayAdapter
在微調器中顯示默認文本和我不明白錯誤無法解析構造函數ArrayAdapter(android.content.Context,int,java.lang.String [],java.lang.String,java.lang.String)
無法解析構造函數ArrayAdapter(android.content.Context,int,java.lang.String [],java.lang.String,java.lang.String)。
任何人都可以告訴我這個,請幫助我我不太瞭解java編碼。
public class UneCon extends Fragment {
private Spinner fromDetails, toDetails;
private EditText fromInput, toInput;
public static UneCon setArguments(int position) {
UniqueConverter uniqueConverter = new UniqueConverter();
Bundle args = new Bundle();
args.putInt("position", position);
uniqueConverter.setArguments(args);
return uniqueConverter;
}
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_uniquelayout, container, false);
onInitVies(view);
int position = getArguments().getInt("position");
switch (position) {
case 0:
setAdapter(getResources().getStringArray(R.array.temperatureform), "Celsius", "Fahrenheit");
break;
case 1:
setAdapter(getResources().getStringArray(R.array.weightform), "Kilograms", "Grams");
break;
return view;
}
private void setAdapter(String[] spinnerItems, String fromDefaultText, String toDefaultText) {
fromDetails.setAdapter(new ArrayAdapter<String>(getContext(), R.layout.spinner_item, spinnerItems, fromDefaultText, toDefaultText));//here it getting error//
}
private void onInitVies(View view) {
fromDetails = (Spinner) view.findViewById(R.id.fromSpinner);
toDetails = (Spinner) view.findViewById(R.id.toSpinner);
fromInput = (EditText) view.findViewById(R.id.fromInput);
toInput = (EditText) view.findViewById(R.id.toInput);
}
}
谷歌它。在這裏,我發現它: - http://coderzpassion.com/android-working-with-spinner/ –
您正在使用無效的構造函數。看到這個http://developer.android.com/reference/android/widget/ArrayAdapter.html – Rohit5k2