use of android.widget.Spinner in project android_frameworks_base by DirtyUnicorns.
the class ToolbarWidgetWrapper method ensureSpinner.
private void ensureSpinner() {
if (mSpinner == null) {
mSpinner = new Spinner(getContext(), null, R.attr.actionDropDownStyle);
Toolbar.LayoutParams lp = new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.START | Gravity.CENTER_VERTICAL);
mSpinner.setLayoutParams(lp);
}
}
use of android.widget.Spinner in project android_frameworks_base by DirtyUnicorns.
the class BaseActivity method onCreate.
@CallSuper
@Override
public void onCreate(Bundle icicle) {
// Record the time when onCreate is invoked for metric.
mStartTime = new Date().getTime();
super.onCreate(icicle);
final Intent intent = getIntent();
addListenerForLaunchCompletion();
setContentView(mLayoutId);
mDrawer = DrawerController.create(this);
mState = getState(icicle);
Metrics.logActivityLaunch(this, mState, intent);
mRoots = DocumentsApplication.getRootsCache(this);
getContentResolver().registerContentObserver(RootsCache.sNotificationUri, false, mRootsCacheObserver);
mSearchManager = new SearchViewManager(this, icicle);
DocumentsToolbar toolbar = (DocumentsToolbar) findViewById(R.id.toolbar);
setActionBar(toolbar);
mNavigator = new NavigationView(mDrawer, toolbar, (Spinner) findViewById(R.id.stack), mState, this);
// Base classes must update result in their onCreate.
setResult(Activity.RESULT_CANCELED);
}
use of android.widget.Spinner 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.Spinner in project easy by MehdiBenmesa.
the class StudentsFragmentAbsence method startDialog.
public void startDialog(final JSONArray response, final JSONArray pseances, List<String> modules) {
/* List<String> modules = new ArrayList<String>();
final JSONArray seances = new JSONArray();
try{
for (int i =0;i<response.length();i++) {
JSONObject seance = response.getJSONObject(i);
JSONObject idmodule = seance.getJSONObject("module");
if(idmodule.getString("_id").equals(module.getString("_id"))){
String type = "";
try{
type = seance.getString("type") + " de : ";
}catch (Exception e){
e.printStackTrace();
type = "heur de : ";
}
String seanceSpinner = type + seance.getString("starts") + " à "+seance.getString("ends");
modules.add(seanceSpinner);
seances.put(seance);
}
}} catch (JSONException e){
e.printStackTrace();
}*/
addDialog = getActivity().getLayoutInflater().inflate(R.layout.absence_dialog, null);
final TextView nom = (TextView) addDialog.findViewById(R.id.nomdialog);
final Spinner etat = (Spinner) addDialog.findViewById(R.id.okdialog);
ArrayAdapter<String> adap = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, modules);
adap.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
etat.setAdapter(adap);
nom.setText("");
dialog = new LovelyCustomDialog(getContext(), R.style.EditTextTintTheme).setTopColorRes(R.color.darkRed).setView(addDialog).setTitle(R.string.text_input_title).setIcon(R.drawable.ic_add_alert_black_24dp).setCancelable(false);
dialog.show();
Button ok = (Button) addDialog.findViewById(R.id.ok);
Button annuler = (Button) addDialog.findViewById(R.id.cancel);
ok.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try {
String module = etat.getSelectedItem().toString();
} catch (Exception e) {
System.out.println("NO MODULE ");
}
try {
int position = etat.getSelectedItemPosition();
AbsenceService.getAbsneceBySeance(getContext(), mReceiver, new JSONObject().put("idSeance", pseances.getJSONObject(position).getString("_id")).put("date", newDate));
} catch (JSONException e) {
e.printStackTrace();
}
dialog.dismiss();
}
});
annuler.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
}
use of android.widget.Spinner in project recyclerview-animators by wasabeef.
the class AnimatorSampleActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_animator_sample);
Toolbar toolbar = (Toolbar) findViewById(R.id.tool_bar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.list);
if (getIntent().getBooleanExtra("GRID", true)) {
recyclerView.setLayoutManager(new GridLayoutManager(this, 2));
} else {
recyclerView.setLayoutManager(new LinearLayoutManager(this));
}
recyclerView.setItemAnimator(new SlideInLeftAnimator());
final MainAdapter adapter = new MainAdapter(this, new ArrayList<>(Arrays.asList(data)));
recyclerView.setAdapter(adapter);
Spinner spinner = (Spinner) findViewById(R.id.spinner);
ArrayAdapter<String> spinnerAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1);
for (Type type : Type.values()) {
spinnerAdapter.add(type.name());
}
spinner.setAdapter(spinnerAdapter);
spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
recyclerView.setItemAnimator(Type.values()[position].getAnimator());
recyclerView.getItemAnimator().setAddDuration(500);
recyclerView.getItemAnimator().setRemoveDuration(500);
}
@Override
public void onNothingSelected(AdapterView<?> parent) {
}
});
findViewById(R.id.add).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.add("newly added item", 1);
}
});
findViewById(R.id.del).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
adapter.remove(1);
}
});
}
Aggregations