use of android.widget.SpinnerAdapter in project materialistic by hidroh.
the class SpinnerPreference method onBindViewHolder.
@Override
public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder);
final Spinner spinner = (Spinner) holder.findViewById(R.id.spinner);
holder.itemView.setOnClickListener(v -> spinner.performClick());
spinner.setAdapter(new SpinnerAdapter() {
@Override
public View getDropDownView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = createDropDownView(position, parent);
}
bindDropDownView(position, convertView);
return convertView;
}
@Override
public void registerDataSetObserver(DataSetObserver observer) {
// no op
}
@Override
public void unregisterDataSetObserver(DataSetObserver observer) {
// no op
}
@Override
public int getCount() {
return mEntries.length;
}
@Override
public Object getItem(int position) {
// not applicable
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public boolean hasStableIds() {
return true;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
return getDropDownView(position, convertView, parent);
}
@Override
public int getItemViewType(int position) {
return 0;
}
@Override
public int getViewTypeCount() {
return 1;
}
@Override
public boolean isEmpty() {
return false;
}
});
spinner.setSelection(mSelection);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
mSelection = position;
persistString(mEntryValues[position]);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
// no op
}
});
}
use of android.widget.SpinnerAdapter in project Jota-Text-Editor-old by jiro-aqua.
the class FileSelectorActivity method selectItemOfSpinner.
private void selectItemOfSpinner(Spinner spinner, String s) {
SpinnerAdapter adapter = spinner.getAdapter();
int max = adapter.getCount();
for (int i = 0; i < max; i++) {
String item = (String) adapter.getItem(i);
if (s.equals(item)) {
spinner.setSelection(i);
break;
}
}
return;
}
use of android.widget.SpinnerAdapter in project xabber-android by redsolution.
the class NoDefaultSpinner method setAdapter.
@Override
public void setAdapter(SpinnerAdapter orig) {
final SpinnerAdapter adapter = newProxy(orig);
super.setAdapter(adapter);
try {
final Method m = AdapterView.class.getDeclaredMethod("setNextSelectedPositionInt", int.class);
m.setAccessible(true);
m.invoke(this, -1);
final Method n = AdapterView.class.getDeclaredMethod("setSelectedPositionInt", int.class);
n.setAccessible(true);
n.invoke(this, -1);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of android.widget.SpinnerAdapter in project howabout-android by recomio.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
categoryStrings = getResources().getStringArray(R.array.category_list);
musicPlaylistTitle = getResources().getString(R.string.title_activity_music_playlist);
exit = getResources().getString(R.string.exit);
ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
actionBar.setDisplayShowTitleEnabled(false);
// dropdown menu in actionBar.
final SpinnerAdapter spinnerAdapter = ArrayAdapter.createFromResource(this, R.array.category_list, android.R.layout.simple_list_item_1);
actionBar.setListNavigationCallbacks(spinnerAdapter, new HowaboutDropdownNavigationListener());
// set framgents.
adultCategoryWrapFragment = new AdultCategoryWrapFragment();
Bundle adultCategoryWrapFragmentBundle = new Bundle();
adultCategoryWrapFragmentBundle.putString("category", "adult");
adultCategoryWrapFragment.setArguments(adultCategoryWrapFragmentBundle);
musicCategoryWrapFragment = new MusicCategoryWrapFragment();
Bundle musicCategoryWrapFragmentBundle = new Bundle();
musicCategoryWrapFragmentBundle.putString("category", "music");
musicCategoryWrapFragment.setArguments(musicCategoryWrapFragmentBundle);
setAdsContainer(R.id.adView);
}
use of android.widget.SpinnerAdapter in project robolectric by robolectric.
the class ShadowAbsSpinner method setSelection.
@Implementation
public void setSelection(int position) {
directlyOn(realAbsSpinner, AbsSpinner.class, "setSelection", ClassParameter.from(int.class, position));
SpinnerAdapter adapter = realAbsSpinner.getAdapter();
if (getItemSelectedListener() != null && adapter != null) {
getItemSelectedListener().onItemSelected(realAbsSpinner, null, position, adapter.getItemId(position));
}
}
Aggregations