Search in sources :

Example 61 with Spinner

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);
    }
}
Also used : Spinner(android.widget.Spinner) Toolbar(android.widget.Toolbar)

Example 62 with Spinner

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);
}
Also used : Spinner(android.widget.Spinner) Intent(android.content.Intent) Date(java.util.Date) CallSuper(android.support.annotation.CallSuper)

Example 63 with Spinner

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
        }
    });
}
Also used : SpinnerAdapter(android.widget.SpinnerAdapter) Spinner(android.widget.Spinner) ViewGroup(android.view.ViewGroup) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) DataSetObserver(android.database.DataSetObserver)

Example 64 with Spinner

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();
        }
    });
}
Also used : Spinner(android.widget.Spinner) JSONException(org.json.JSONException) BindView(butterknife.BindView) View(android.view.View) TextView(android.widget.TextView) RecyclerView(android.support.v7.widget.RecyclerView) JSONException(org.json.JSONException) JSONObject(org.json.JSONObject) Button(android.widget.Button) LovelyCustomDialog(com.yarolegovich.lovelydialog.LovelyCustomDialog) TextView(android.widget.TextView) ArrayAdapter(android.widget.ArrayAdapter)

Example 65 with Spinner

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);
        }
    });
}
Also used : Spinner(android.widget.Spinner) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) GridLayoutManager(android.support.v7.widget.GridLayoutManager) SlideInLeftAnimator(jp.wasabeef.recyclerview.animators.SlideInLeftAnimator) RecyclerView(android.support.v7.widget.RecyclerView) AdapterView(android.widget.AdapterView) ArrayAdapter(android.widget.ArrayAdapter) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Spinner (android.widget.Spinner)160 View (android.view.View)70 AdapterView (android.widget.AdapterView)58 TextView (android.widget.TextView)51 ArrayAdapter (android.widget.ArrayAdapter)50 LinearLayout (android.widget.LinearLayout)29 EditText (android.widget.EditText)20 Intent (android.content.Intent)19 Button (android.widget.Button)19 RecyclerView (android.support.v7.widget.RecyclerView)18 CompoundButton (android.widget.CompoundButton)16 ViewGroup (android.view.ViewGroup)13 ImageView (android.widget.ImageView)13 DialogInterface (android.content.DialogInterface)12 CheckBox (android.widget.CheckBox)11 ListView (android.widget.ListView)11 ArrayList (java.util.ArrayList)11 AutoCompleteTextView (android.widget.AutoCompleteTextView)9 AlertDialog (android.app.AlertDialog)7 LayoutInflater (android.view.LayoutInflater)7