Search in sources :

Example 1 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project qksms by moezbhatti.

the class QKDialog method setDoubleLineItems.

public QKDialog setDoubleLineItems(String[] titles, String[] bodies, final OnItemClickListener onClickListener) {
    int size = Math.min(titles.length, bodies.length);
    DoubleLineListItem[] doubleLineListItems = new DoubleLineListItem[size];
    for (int i = 0; i < size; i++) {
        doubleLineListItems[i] = new DoubleLineListItem();
        doubleLineListItems[i].title = titles[i];
        doubleLineListItems[i].body = bodies[i];
    }
    ArrayAdapter adapter = new DoubleLineArrayAdapter(mContext, doubleLineListItems);
    ListView listView = new ListView(mContext);
    listView.setAdapter(adapter);
    listView.setDivider(null);
    listView.setPadding(0, Units.dpToPx(mContext, 8), 0, Units.dpToPx(mContext, 8));
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (onClickListener != null) {
                onClickListener.onItemClick(parent, view, position, id);
                dismiss();
            }
        }
    });
    return setCustomView(listView);
}
Also used : ListView(android.widget.ListView) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) QKTextView(com.moez.QKSMS.ui.view.QKTextView) View(android.view.View) AdapterView(android.widget.AdapterView) RecyclerView(android.support.v7.widget.RecyclerView) ScrollView(android.widget.ScrollView) ListView(android.widget.ListView) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project SlidingMenu by jfeinstein10.

the class BirdGridFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (mPos == -1 && savedInstanceState != null)
        mPos = savedInstanceState.getInt("mPos");
    TypedArray imgs = getResources().obtainTypedArray(R.array.birds_img);
    mImgRes = imgs.getResourceId(mPos, -1);
    GridView gv = (GridView) inflater.inflate(R.layout.list_grid, null);
    gv.setBackgroundResource(android.R.color.black);
    gv.setAdapter(new GridAdapter());
    gv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (getActivity() == null)
                return;
            ResponsiveUIActivity activity = (ResponsiveUIActivity) getActivity();
            activity.onBirdPressed(mPos);
        }
    });
    return gv;
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) TypedArray(android.content.res.TypedArray) GridView(android.widget.GridView) GridView(android.widget.GridView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 3 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Klyph by jonathangerbaud.

the class MultiSelectDragListPreference method onPrepareDialogBuilder.

@Override
protected void onPrepareDialogBuilder(Builder builder) {
    super.onPrepareDialogBuilder(builder);
    if (mEntries == null || mEntryValues == null) {
        throw new IllegalStateException("MultiSelectListPreference requires an entries array and " + "an entryValues array.");
    }
    String[] entries = new String[mEntries.length];
    for (int i = 0; i < mEntries.length; i++) {
        entries[i] = mEntries[i].toString();
    }
    boolean[] selectedItems = getSelectedItems();
    ArrayList<String> orderedList = new ArrayList<String>();
    int n = selectedItems.length;
    for (String value : mValues) {
        int index = ArrayUtils.indexOf(mEntryValues, value);
        orderedList.add(mEntries[index].toString());
    }
    for (int i = 0; i < mEntries.length; i++) {
        if (!mValues.contains(mEntryValues[i]))
            orderedList.add(mEntries[i].toString());
    }
    adapter = new ArrayAdapter<String>(getContext(), R.layout.item_list_preference_multi_drag, R.id.text, orderedList);
    listView = new DragSortListView(getContext(), null);
    listView.setAdapter(adapter);
    listView.setDropListener(onDrop);
    listView.setDragEnabled(true);
    listView.setFloatAlpha(0.8f);
    DragSortController controller = new DragSortController(listView);
    controller.setDragHandleId(R.id.drag_handle);
    controller.setRemoveEnabled(false);
    controller.setSortEnabled(true);
    controller.setBackgroundColor(0xFFFFFF);
    controller.setDragInitMode(DragSortController.ON_DOWN);
    listView.setFloatViewManager(controller);
    listView.setOnTouchListener(controller);
    builder.setView(listView);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            mPreferenceChanged = true;
            refreshNewValues();
        }
    });
    listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    for (int i = 0; i < n; i++) {
        listView.setItemChecked(i, i < mValues.size());
    }
    /*
		 * boolean [] checkedItems = getSelectedItems();
		 * builder.setMultiChoiceItems(mEntries, checkedItems,
		 * new DialogInterface.OnMultiChoiceClickListener() {
		 * public void onClick(DialogInterface dialog, int which, boolean 
		 * isChecked) {
		 * if (isChecked) {
		 * mPreferenceChanged |= mNewValues.add(mEntryValues[which].toString());
		 * } else {
		 * mPreferenceChanged |=
		 * mNewValues.remove(mEntryValues[which].toString());
		 * }
		 * }
		 * });
		 */
    mNewValues.clear();
    mNewValues.addAll(mValues);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) DragSortListView(com.mobeta.android.dslv.DragSortListView) DragSortListView(com.mobeta.android.dslv.DragSortListView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) DragSortController(com.mobeta.android.dslv.DragSortController)

Example 4 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project Klyph by jonathangerbaud.

the class GalleryFragment method onViewCreated.

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    loadingView = (ProgressBar) view.findViewById(android.R.id.progress);
    setListVisible(false);
    super.onViewCreated(view, savedInstanceState);
    imageUris = new ArrayList<String>();
    getGridView().setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    getGridView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> gridView, View view, int position, long id) {
            GraphObject o = getAdapter().getItem(position);
            if (o instanceof CameraObject) {
                Intent intent = new Intent(getActivity(), GalleryActivity.class);
                intent.putExtra(KlyphBundleExtras.CAMERA_PICTURES, true);
                intent.putStringArrayListExtra(KlyphBundleExtras.PHOTO_LIST_URI, (ArrayList<String>) initUris);
                startActivityForResult(intent, CAMERA_GALLERY_CODE);
            } else {
                if (!Android.isMinAPI(11)) {
                    CheckableGalleryLayout cgl = (CheckableGalleryLayout) view;
                    cgl.toggle();
                    Picture image = (Picture) o;
                    image.setSelected(cgl.isChecked());
                }
                if (actionMode == null)
                    actionMode = getActivity().startActionMode(mActionModeCallback);
                refreshActionModeTitle();
            }
        }
    });
    showCamera = !getActivity().getIntent().getBooleanExtra(KlyphBundleExtras.CAMERA_PICTURES, false);
    hasCamera = getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) || getActivity().getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT);
    defineEmptyText(R.string.empty_list_no_photo);
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ArrayList(java.util.ArrayList) Intent(android.content.Intent) GalleryActivity(com.abewy.android.apps.klyph.app.GalleryActivity) GraphObject(com.abewy.android.apps.klyph.core.graph.GraphObject) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) CheckableGalleryLayout(com.abewy.android.apps.klyph.widget.CheckableGalleryLayout)

Example 5 with OnItemClickListener

use of android.widget.AdapterView.OnItemClickListener in project LitePal by LitePalFramework.

the class ModelListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.model_list_layout);
    mModelListview = (ListView) findViewById(R.id.model_listview);
    populateMappingClasses();
    mAdapter = new StringArrayAdapter(this, 0, mList);
    mModelListview.setAdapter(mAdapter);
    mModelListview.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View view, int index, long id) {
            ModelStructureActivity.actionStart(ModelListActivity.this, mList.get(index));
        }
    });
}
Also used : StringArrayAdapter(org.litepal.litepalsample.adapter.StringArrayAdapter) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView)

Aggregations

OnItemClickListener (android.widget.AdapterView.OnItemClickListener)241 AdapterView (android.widget.AdapterView)238 View (android.view.View)237 ListView (android.widget.ListView)188 TextView (android.widget.TextView)135 ImageView (android.widget.ImageView)86 Intent (android.content.Intent)68 OnClickListener (android.view.View.OnClickListener)44 SuppressLint (android.annotation.SuppressLint)32 LayoutInflater (android.view.LayoutInflater)32 AlertDialog (android.app.AlertDialog)27 DialogInterface (android.content.DialogInterface)27 GridView (android.widget.GridView)26 ArrayAdapter (android.widget.ArrayAdapter)24 Bundle (android.os.Bundle)23 Dialog (android.app.Dialog)22 ArrayList (java.util.ArrayList)21 Paint (android.graphics.Paint)17 File (java.io.File)17 AbsListView (android.widget.AbsListView)16