Как установить счетчик. Значение первой позиции списка отображается пустым, я подключил адаптер и занятие: любезно решите мою проблему.
SpinnerAdapterIdtypeMaster
public class SpinnerAdapterIdtypeMaster extends ArrayAdapter {
private Context mContext;
private List<CMSSubMasterDB> spinnerList = new ArrayList<>();
private MasterType type;
public SpinnerAdapterIdtypeMaster(@NonNull Context context, List<CMSSubMasterDB> list) {
super(context, 0, list);
mContext = context;
spinnerList = list;
}
@Override
public View getDropDownView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
return getCustomView(position, convertView, parent);
}
@Override
public int getCount() {
return spinnerList.size();
}
@Nullable
@Override
public CMSSubMasterDB getItem(int position) {
return spinnerList.get(position);
}
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
View listItem = convertView;
if (listItem == null)
listItem = LayoutInflater.from(mContext).inflate(R.layout.spinner_list, parent, false);
CMSSubMasterDB currentMovie = spinnerList.get(position);
TextView name = (TextView) listItem.findViewById(R.id.spinner);
name.setText(currentMovie.name);
return listItem;
}
public View getCustomView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
//return super.getView(position, convertView, parent);
View listItem = convertView;
if (listItem == null)
listItem = LayoutInflater.from(mContext).inflate(R.layout.spinner_list, parent, false);
TextView label = (TextView) listItem.findViewById(R.id.spinner);
label.setText(spinnerList.get(position).name);
return listItem;
}
}
CreateRyotManagerFragment
public class CreateRyotManagerFragment extends Fragment {
Spinner mIDType
List<CMSSubMasterDB> mIdtypeMasterList;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
view = inflater.inflate(R.layout.layout_new_ryot, container, false);
mIDType = view.findViewById(R.id.idtype);
mIdtypeMasterList = AppUtils.getIDTypeMasterDb();
SpinnerAdapterIdtypeMaster idTypeMaster = new SpinnerAdapterIdtypeMaster(getActivity().getApplicationContext(), mIdtypeMasterList);
mIDType.setAdapter(idTypeMaster);
return view;
}
}