当自定义适配器为空时,如何在Spinner中设置提示。
我的适配器列表:
public class DeviceAdapter extends ArrayAdapter<NetworkDevice> {
public DeviceAdapter(Context context, List<NetworkDevice> devices) {
super(context, R.layout.spinner_cell, devices);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
NetworkDevice device = getItem(position);
if (convertView == null)
convertView = LayoutInflater.from(getContext())
.inflate(R.layout.spinner_cell, null);
TextView txtCurrentSpinnerCell = convertView.findViewById(R.id.txtSelectedServiceName);
return convertView;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
NetworkDevice device = getItem(position);
if (convertView == null)
convertView = LayoutInflater.from(getContext())
.inflate(R.layout.spinner_selection_cell, null);
TextView txtSpinnerCell = convertView.findViewById(R.id.txtServiceName);
txtSpinnerCell.setText(device.getName());
TextView txtIpAddress = convertView.findViewById(R.id.txtIpAddress);
txtIpAddress.setText(device.getIp());
return convertView;
}
}
如何实施?任何想法...
提前谢谢。问候...)