Search in sources :

Example 56 with AdapterView

use of android.widget.AdapterView in project coursera-android by aporter.

the class SpinnerActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    // Get a reference to the Spinner
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    // Create an Adapter that holds a list of colors
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.colors, R.layout.dropdown_item);
    // Set the Adapter for the spinner
    spinner.setAdapter(adapter);
    // Set an setOnItemSelectedListener on the spinner
    spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

        public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) {
            // Display a Toast message indicating the currently selected
            // item
            Toast.makeText(parent.getContext(), "The color is " + parent.getItemAtPosition(pos).toString(), Toast.LENGTH_LONG).show();
        }

        public void onNothingSelected(AdapterView<?> parent) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) OnItemSelectedListener(android.widget.AdapterView.OnItemSelectedListener) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 57 with AdapterView

use of android.widget.AdapterView in project coursera-android by aporter.

the class GridFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    mGridview.setAdapter(new ImageAdapter(getActivity(), mThumbNailIDs));
    mGridview.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            Intent intent = new Intent(getActivity(), ImageViewActivity.class);
            intent.putExtra(EXTRA_RES_ID, (int) id);
            startActivity(intent);
        }
    });
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) Intent(android.content.Intent) GridView(android.widget.GridView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 58 with AdapterView

use of android.widget.AdapterView in project RecyclerViewItemAnimators by gabrielemariotti.

the class AnimationGridActivity method setupSpinner.

private void setupSpinner() {
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.adapters, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            switch(position) {
                case 0:
                    AlphaAnimatorAdapter animatorAdapter = new AlphaAnimatorAdapter(mAdapter, mRecyclerView);
                    mRecyclerView.setAdapter(animatorAdapter);
                    break;
                case 1:
                    SlideInLeftAnimatorAdapter slideInLeftAnimationRecyclerViewAdapter = new SlideInLeftAnimatorAdapter(mAdapter, mRecyclerView);
                    mRecyclerView.setAdapter(slideInLeftAnimationRecyclerViewAdapter);
                    break;
                case 2:
                    SlideInRightAnimatorAdapter slideInRightAnimatorAdapter = new SlideInRightAnimatorAdapter(mAdapter, mRecyclerView);
                    mRecyclerView.setAdapter(slideInRightAnimatorAdapter);
                    break;
                case 3:
                    SlideInBottomAnimatorAdapter slideInBottomAnimatorAdapter = new SlideInBottomAnimatorAdapter(mAdapter, mRecyclerView);
                    mRecyclerView.setAdapter(slideInBottomAnimatorAdapter);
                    break;
                case 4:
                    ScaleInAnimatorAdapter scaleInRecyclerViewAnimationAdapter = new ScaleInAnimatorAdapter(mAdapter, mRecyclerView);
                    mRecyclerView.setAdapter(scaleInRecyclerViewAnimationAdapter);
                    break;
                case 5:
                    SwingBottomInAnimationAdapter swingBottomInAnimationAdapter = new SwingBottomInAnimationAdapter(mAdapter, mRecyclerView);
                    mRecyclerView.setAdapter(swingBottomInAnimationAdapter);
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) SwingBottomInAnimationAdapter(it.gmariotti.recyclerview.adapter.SwingBottomInAnimationAdapter) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) SlideInBottomAnimatorAdapter(it.gmariotti.recyclerview.adapter.SlideInBottomAnimatorAdapter) ScaleInAnimatorAdapter(it.gmariotti.recyclerview.adapter.ScaleInAnimatorAdapter) SlideInLeftAnimatorAdapter(it.gmariotti.recyclerview.adapter.SlideInLeftAnimatorAdapter) AlphaAnimatorAdapter(it.gmariotti.recyclerview.adapter.AlphaAnimatorAdapter) AdapterView(android.widget.AdapterView) SlideInRightAnimatorAdapter(it.gmariotti.recyclerview.adapter.SlideInRightAnimatorAdapter)

Example 59 with AdapterView

use of android.widget.AdapterView in project RecyclerViewItemAnimators by gabrielemariotti.

the class ListActivity method setupSpinner.

private void setupSpinner() {
    Spinner spinner = (Spinner) findViewById(R.id.spinner);
    // Create an ArrayAdapter using the string array and a default spinner layout
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.animators, android.R.layout.simple_spinner_item);
    // Specify the layout to use when the list of choices appears
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    // Apply the adapter to the spinner
    spinner.setAdapter(adapter);
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {

        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int position, long l) {
            switch(position) {
                case 0:
                    mRecyclerView.setItemAnimator(new SlideInOutLeftItemAnimator(mRecyclerView));
                    break;
                case 1:
                    mRecyclerView.setItemAnimator(new SlideInOutRightItemAnimator(mRecyclerView));
                    break;
                case 2:
                    mRecyclerView.setItemAnimator(new SlideInOutTopItemAnimator(mRecyclerView));
                    break;
                case 3:
                    mRecyclerView.setItemAnimator(new SlideInOutBottomItemAnimator(mRecyclerView));
                    break;
                case 4:
                    mRecyclerView.setItemAnimator(new ScaleInOutItemAnimator(mRecyclerView));
                    break;
                case 5:
                    mRecyclerView.setItemAnimator(new SlideScaleInOutRightItemAnimator(mRecyclerView));
                    break;
            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
}
Also used : Spinner(android.widget.Spinner) SlideInOutTopItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutTopItemAnimator) SlideInOutRightItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutRightItemAnimator) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View) AdapterView(android.widget.AdapterView) SlideInOutLeftItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutLeftItemAnimator) ScaleInOutItemAnimator(it.gmariotti.recyclerview.itemanimator.ScaleInOutItemAnimator) SlideScaleInOutRightItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideScaleInOutRightItemAnimator) AdapterView(android.widget.AdapterView) SlideInOutBottomItemAnimator(it.gmariotti.recyclerview.itemanimator.SlideInOutBottomItemAnimator)

Example 60 with AdapterView

use of android.widget.AdapterView in project FBReaderJ by geometer.

the class ViewFilesContextMenuUtils method doShowHistoryContents.

/**
     * Shows history contents to the user. He can clear all items.
     * 
     * @param context
     *            {@link Context}
     * @param fileProvider
     *            {@link IFileProvider}
     * @param history
     *            {@link History} of {@link IFile}.
     * @param currentLocation
     *            current location, will not be shown.
     * @param listener
     *            will be notified after the user closed the dialog, or when the
     *            user selects an item.
     */
public static void doShowHistoryContents(final Context context, final IFileProvider fileProvider, final History<IFile> history, IFile currentLocation, final TaskListener listener) {
    if (history.isEmpty())
        return;
    final AlertDialog _dialog = Dlg.newDlg(context);
    // don't use Cancel button
    _dialog.setButton(DialogInterface.BUTTON_NEGATIVE, null, (DialogInterface.OnClickListener) null);
    _dialog.setIcon(android.R.drawable.ic_dialog_info);
    _dialog.setTitle(R.string.afc_title_history);
    List<IFileDataModel> data = new ArrayList<IFileDataModel>();
    ArrayList<IFile> items = history.items();
    for (int i = items.size() - 1; i >= 0; i--) {
        IFile f = items.get(i);
        if (f == currentLocation)
            continue;
        // check for duplicates
        boolean duplicated = false;
        for (int j = 0; j < data.size(); j++) {
            if (f.equalsToPath(data.get(j).getFile())) {
                duplicated = true;
                break;
            }
        }
        if (!duplicated)
            data.add(new IFileDataModel(f));
    }
    final IFileAdapter _adapter = new IFileAdapter(context, data, FilterMode.DirectoriesOnly, null, false);
    ListView listView = (ListView) LayoutInflater.from(context).inflate(R.layout.afc_listview_files, null);
    listView.setBackgroundResource(0);
    listView.setFastScrollEnabled(true);
    listView.setAdapter(_adapter);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (listener != null) {
                _dialog.dismiss();
                listener.onFinish(true, _adapter.getItem(position).getFile());
            }
        }
    });
    // OnItemClickListener
    _dialog.setView(listView);
    _dialog.setButton(DialogInterface.BUTTON_POSITIVE, context.getString(R.string.afc_cmd_clear), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
            history.clear();
        }
    });
    _dialog.setOnCancelListener(new DialogInterface.OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            if (listener != null)
                listener.onFinish(true, null);
        }
    });
    _dialog.show();
}
Also used : AlertDialog(android.app.AlertDialog) IFileAdapter(group.pals.android.lib.ui.filechooser.IFileAdapter) IFile(group.pals.android.lib.ui.filechooser.io.IFile) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) ListView(android.widget.ListView) IFileDataModel(group.pals.android.lib.ui.filechooser.IFileDataModel) AdapterView(android.widget.AdapterView)

Aggregations

AdapterView (android.widget.AdapterView)677 View (android.view.View)653 ListView (android.widget.ListView)412 TextView (android.widget.TextView)342 Intent (android.content.Intent)177 ImageView (android.widget.ImageView)174 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)142 ArrayAdapter (android.widget.ArrayAdapter)75 ArrayList (java.util.ArrayList)71 ViewGroup (android.view.ViewGroup)63 AbsListView (android.widget.AbsListView)59 GridView (android.widget.GridView)58 Bundle (android.os.Bundle)53 Spinner (android.widget.Spinner)50 LinearLayout (android.widget.LinearLayout)49 OnClickListener (android.view.View.OnClickListener)46 RecyclerView (android.support.v7.widget.RecyclerView)42 DialogInterface (android.content.DialogInterface)41 SuppressLint (android.annotation.SuppressLint)38 LayoutInflater (android.view.LayoutInflater)34