Skip to content

Instantly share code, notes, and snippets.

@caneryilmaz
Created September 20, 2018 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caneryilmaz/dfe0bef81e8c9f66c9cda5b008de3fa5 to your computer and use it in GitHub Desktop.
Save caneryilmaz/dfe0bef81e8c9f66c9cda5b008de3fa5 to your computer and use it in GitHub Desktop.
public class BlockedTypeAdapter extends ArrayAdapter<EngellilikKategorileri> {
private List<EngellilikKategorileri> items;
public BlockedTypeAdapter(Context context, List<EngellilikKategorileri> objects) {
super(context, 0, objects);
this.items = objects;
}
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
TextView label = (TextView) super.getDropDownView(position, convertView, parent);
label.setTextColor(Color.BLACK);
label.setText(items.get(position).getTurAdi());
return label;
}
@Override
public int getCount() {
return items.size();
}
@Override
public EngellilikKategorileri getItem(int position) {
return items.get(position);
}
@Override
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.layout_tag_text, null);
}
EngellilikKategorileri item = items.get(position);
if (item != null) {
TextView tt = v.findViewById(R.id.text_city_name);
tt.setTextSize(15);
tt.setText(item.getTurAdi().toString());
}
return v;
}
}
//****************//***
adapter.setDropDownViewResource(android.R.layout.simple_spinner_item);
spinnerBlockedType.setAdapter(adapter);
spinnerBlockedType.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
engellilikBilgi.setKategoriId(list.get(position).getTurId());
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment