Example usage for android.widget AdapterView getItemAtPosition

List of usage examples for android.widget AdapterView getItemAtPosition

Introduction

In this page you can find the example usage for android.widget AdapterView getItemAtPosition.

Prototype

public Object getItemAtPosition(int position) 

Source Link

Document

Gets the data associated with the specified position in the list.

Usage

From source file:org.alfresco.mobile.android.application.extension.scansnap.ScanSnapPresetsDialogFragment.java

public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    final View v = inflater.inflate(R.layout.sdk_list, null);

    ListView lv = (ListView) v.findViewById(R.id.listView);

    lv.setOnItemClickListener(new OnItemClickListener() {
        @Override//from   w  ww  .ja va 2 s  .  c  o m
        public void onItemClick(AdapterView<?> l, View v, int position, long id) {
            ScanSnapManager.getInstance(getActivity()).scan(getActivity(),
                    ((ScanSnapPreset) l.getItemAtPosition(position)).getIdentifier());
            dismiss();
        }
    });

    List<ScanSnapPreset> presets = new ArrayList<>();
    presets.add(new DefaultPreset(getActivity().getApplicationContext().getPackageName()));
    presets.add(new PhotoPreset(getActivity().getApplicationContext().getPackageName()));
    ScanSnapPresetAdapter adapter = new ScanSnapPresetAdapter(getActivity(), R.layout.row_single_line, presets);
    lv.setAdapter(adapter);
    return new AlertDialog.Builder(getActivity()).setTitle(R.string.scan_preset).setView(v).create();
}

From source file:io.valuesfeng.picker.control.AlbumCollection.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    if (directorySelectListener != null) {
        Cursor cursor = (Cursor) parent.getItemAtPosition(position);
        Album album = Album.valueOf(cursor);
        directorySelectListener.onSelect(album);
    }//w w  w .  ja v a2s .  c o  m
}

From source file:org.deviceconnect.android.deviceplugin.fplug.setting.fragment.FPLUGConnectFragment.java

private void setupInitListener(ListView listview) {
    listview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*from w w w . j a v a2  s . com*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final FPlugItem fplug = (FPlugItem) parent.getItemAtPosition(position);
            if (fplug.isConnected) {
                ((SettingActivity) getActivity()).showControllerPage(fplug.mDevice.getAddress());
            } else {
                Toast.makeText(getActivity(), getString(R.string.setting_connect_not_connected),
                        Toast.LENGTH_LONG).show();
            }
        }
    });
}

From source file:de.aw.monma.views.MonMaAutoCompleteTextView.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Cursor c = (Cursor) parent.getItemAtPosition(position);
    c.moveToPosition(position);/*from w w  w  .  j  a va  2s  .com*/
    mLastValidText = c.getString(0);
    mLastSelectedID = c.getLong(1);
    if (mOnTextChangeListener != null) {
        mOnTextChangeListener.onTextChanged(this, mLastValidText, mLastSelectedID);
    }
}

From source file:com.dycode.jepretstory.mediachooser.fragment.BucketVideoFragment.java

private void init() {
    final String orderBy = MediaStore.Video.Media.DATE_TAKEN;
    mCursor = getActivity().getContentResolver().query(MediaStore.Video.Media.EXTERNAL_CONTENT_URI,
            PROJECTION_BUCKET, null, null, orderBy + " DESC");
    ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
    try {/*from  w w  w  .  j  a  va2 s. c  om*/
        while (mCursor.moveToNext()) {
            BucketEntry entry = new BucketEntry(mCursor.getInt(INDEX_BUCKET_ID),
                    mCursor.getString(INDEX_BUCKET_NAME), mCursor.getString(INDEX_BUCKET_URL));

            if (!buffer.contains(entry)) {
                buffer.add(entry);
            }
        }
        if (mCursor.getCount() > 0) {
            mBucketAdapter = new BucketGridAdapter(getActivity(), 0, buffer, true);
            mBucketAdapter.bucketVideoFragment = this;
            mGridView.setAdapter(mBucketAdapter);
        } else {
            Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available),
                    Toast.LENGTH_SHORT).show();
        }
        mGridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {

                BucketEntry bucketEntry = (BucketEntry) adapter.getItemAtPosition(position);
                Intent selectImageIntent = new Intent(getActivity(), HomeFragmentActivity.class);
                selectImageIntent.putExtra("name", bucketEntry.bucketName);
                selectImageIntent.putExtra("isFromBucket", true);
                if (mCurrentSelectedVideos != null) {
                    selectImageIntent.putParcelableArrayListExtra("selectedVideos", mCurrentSelectedVideos);
                }
                getActivity().startActivityForResult(selectImageIntent,
                        MediaChooserConstants.BUCKET_SELECT_VIDEO_CODE);

            }
        });

    } finally {
        mCursor.close();
    }
}

From source file:com.tomeokin.lspush.biz.auth.CountryCodePickerDialog.java

@SuppressLint("InflateParams")
@NonNull//from   ww  w  . j a  va 2s .  co m
@Override
protected Builder config(@NonNull Builder builder) {
    builder.setTitle(getString(R.string.select_your_country).toUpperCase(Locale.getDefault()));

    View view = LayoutInflater.from(getContext()).inflate(R.layout.dialog_country_codes, null);
    ListView listView = (ListView) view.findViewById(R.id.country_code_list);
    searchEditText = (SearchEditText) view.findViewById(R.id.search);
    searchEditText.setOnFilterTextListener(new OnFilterTextListener() {
        @Override
        public void onTextChanged(SearchEditText editText, CharSequence text, int start, int lengthBefore,
                int lengthAfter) {
            String str = StringUtils.removeBlank(text).toLowerCase(Locale.getDefault());
            adapter.clearList();
            if (TextUtils.isEmpty(str)) {
                adapter.restoreList();
                adapter.notifyDataSetChanged();
            } else {
                for (CountryCodeData countryCodeData : adapter.getBackList()) {
                    if (StringUtils.isEqualWithNature(countryCodeData.formatWithDescription(), str, 0)
                            || StringUtils.isEqualWithNature(countryCodeData.countryCode, str, 0)
                            || StringUtils.isEqualWithNature(countryCodeData.formatCountryCode(), str, 0)) {
                        adapter.addCountryCodeData(countryCodeData);
                        adapter.notifyDataSetChanged();
                    }
                }
            }
        }

        @Override
        public void onTextCompleted(SearchEditText editText, String text) {

        }
    });
    ColorFilter colorFilter = ColorFilterCache
            .getColorFilter(ContextCompat.getColor(getContext(), R.color.grey_light));
    searchEditText.getCompoundDrawables()[0].mutate().setColorFilter(colorFilter);
    searchEditText.setClearButtonColorFilter(colorFilter);
    adapter = new CountryCodeDataAdapter(getContext(), countryCodeDatas);
    listView.setAdapter(adapter);

    builder.addCustomMessageView(view);
    builder.setCancelable(true);
    builder.setCanceledOnTouchOutside(true);

    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CountryCodeData countryCodeData = (CountryCodeData) parent.getItemAtPosition(position);
            ((OnCountryCodeSelectedListener) getTargetFragment()).onCountryCodeSelected(countryCodeData);
            getDialog().dismiss();
        }
    });
    return builder;
}

From source file:com.dycode.jepretstory.mediachooser.fragment.BucketImageFragment.java

private void init() {
    final String orderBy = MediaStore.Images.Media.DATE_TAKEN;
    mCursor = getActivity().getContentResolver().query(MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
            PROJECTION_BUCKET, null, null, orderBy + " DESC");
    ArrayList<BucketEntry> buffer = new ArrayList<BucketEntry>();
    try {/*from w w w .  j  a  v  a2s  . com*/
        while (mCursor.moveToNext()) {
            BucketEntry entry = new BucketEntry(mCursor.getInt(INDEX_BUCKET_ID),
                    mCursor.getString(INDEX_BUCKET_NAME), mCursor.getString(INDEX_BUCKET_URL));

            if (!buffer.contains(entry)) {
                buffer.add(entry);
            }
        }

        if (mCursor.getCount() > 0) {
            mBucketAdapter = new BucketGridAdapter(getActivity(), 0, buffer, false);
            mGridView.setAdapter(mBucketAdapter);
        } else {
            Toast.makeText(getActivity(), getActivity().getString(R.string.no_media_file_available),
                    Toast.LENGTH_SHORT).show();
        }

        mGridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {

                BucketEntry bucketEntry = (BucketEntry) adapter.getItemAtPosition(position);
                Intent selectImageIntent = new Intent(getActivity(), HomeFragmentActivity.class);
                selectImageIntent.putExtra("name", bucketEntry.bucketName);
                selectImageIntent.putExtra("image", true);
                selectImageIntent.putExtra("isFromBucket", true);
                if (mCurrentSelectedImages != null) {
                    selectImageIntent.putParcelableArrayListExtra("selectedImages", mCurrentSelectedImages);
                }

                getActivity().startActivityForResult(selectImageIntent,
                        MediaChooserConstants.BUCKET_SELECT_IMAGE_CODE);
            }
        });

    } finally {
        mCursor.close();
    }
}

From source file:com.appjma.appdeployer.AppsFragment.java

@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Cursor c = (Cursor) parent.getItemAtPosition(position);
    String appId = c.getString(AppsAdapter.PROJECTION_APP_ID);
    startActivity(new Intent(Intent.ACTION_VIEW, Uri.withAppendedPath(AppContract.Apps.CONTENT_URI, appId)));
}

From source file:it.jaschke.alexandria.fragment.ListFragment.java

private void onItemClicked(AdapterView<?> adapterView, int position) {
    Cursor cursor = (Cursor) adapterView.getItemAtPosition(position);
    if (cursor != null) {
        String isbn = cursor.getString(cursor.getColumnIndex(BookContract.BookEntry._ID));
        Uri uri = BookContract.BookEntry.buildBookUri(Long.parseLong(isbn));
        ((Callback) getActivity()).onItemSelected(uri);
    }//from w  w  w. j  av a 2s  .  c o m
}

From source file:net.wespot.pim.utils.layout.NoticeDialogFragment.java

@Override
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
    parent.getItemAtPosition(position);

    audio = false;//from w w  w.j  a  v a  2s .  c o  m
    video = false;
    image = false;
    text = false;
    number = false;

    if (parent.getSelectedItem().equals("Audio")) {
        audio = true;
    }
    if (parent.getSelectedItem().equals("Video")) {
        video = true;
    }
    if (parent.getSelectedItem().equals("Picture")) {
        image = true;
    }
    if (parent.getSelectedItem().equals("Text")) {
        text = true;
    }
    if (parent.getSelectedItem().equals("Number")) {
        number = true;
    }
}