Java Code Examples for android.widget.AdapterView#OnItemClickListener

The following examples show how to use android.widget.AdapterView#OnItemClickListener . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditHopActivity.java    From biermacht with Apache License 2.0 6 votes vote down vote up
@Override
public void configureSearchableListListener() {
  searchableListListener = new AdapterView.OnItemClickListener() {

    public void onItemClick(AdapterView<?> parentView, View selectedItemView, int position, long id) {
      selectedHop = (Hop) filteredList.get(position);

      // Set values for this hop.
      setValues(selectedHop);

      // Cancel dialog.
      if (dialog != null) {
        dialog.cancel();
        dialog = null;
      }
    }
  };
}
 
Example 2
Source File: InternalHelper.java    From SimpleAlertDialog-for-Android with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.FROYO)
private void setItems(Bundle args, final SimpleAlertDialog dialog, final int requestCode) {
    if (!hasItemClickListener()) {
        return;
    }
    CharSequence[] items;
    if (has(args, SimpleAlertDialog.ARG_ITEMS) && Build.VERSION_CODES.ECLAIR <= Build.VERSION.SDK_INT) {
        items = args.getCharSequenceArray(SimpleAlertDialog.ARG_ITEMS);
    } else if (has(args, SimpleAlertDialog.ARG_ITEMS_RES_ID)) {
        items = getActivity().getResources().getTextArray(args.getInt(SimpleAlertDialog.ARG_ITEMS_RES_ID));
    } else {
        return;
    }
    int[] icons = null;
    if (has(args, SimpleAlertDialog.ARG_ICONS)) {
        icons = args.getIntArray(SimpleAlertDialog.ARG_ICONS);
    }
    if (fragmentImplements(SimpleAlertDialog.OnItemClickListener.class)
            || activityImplements(SimpleAlertDialog.OnItemClickListener.class)) {
        AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (fragmentImplements(SimpleAlertDialog.OnItemClickListener.class)) {
                    ((SimpleAlertDialog.OnItemClickListener) getTargetFragment())
                            .onItemClick(dialog, requestCode, position);
                }
                if (activityImplements(SimpleAlertDialog.OnItemClickListener.class)) {
                    ((SimpleAlertDialog.OnItemClickListener) getActivity())
                            .onItemClick(dialog, requestCode, position);
                }
            }
        };
        if (icons == null) {
            dialog.setItems(items, listener);
        } else {
            dialog.setItems(items, icons, listener);
        }
    }
}
 
Example 3
Source File: SimpleAlertDialog.java    From SimpleAlertDialog-for-Android with Apache License 2.0 5 votes vote down vote up
public void setItems(final CharSequence[] items,
                     final int[] iconResIds,
                     final AdapterView.OnItemClickListener listener) {
    if (iconResIds == null || items == null) {
        return;
    }
    final IconListItem[] iconListItems = new IconListItem[Math.min(iconResIds.length, items.length)];
    for (int i = 0; i < iconResIds.length && i < items.length; i++) {
        iconListItems[i] = new IconListItem(iconResIds[i], items[i]);
    }
    mAdapter = new ArrayAdapter<IconListItem>(getContext(), android.R.layout.simple_list_item_1, iconListItems) {
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            View view = super.getView(position, convertView, parent);
            if (view != null) {
                TextView tv = (TextView) view.findViewById(android.R.id.text1);
                if (mListItemTextStyle != 0) {
                    tv.setTextAppearance(getContext(), mListItemTextStyle);
                }
                tv.setText(iconListItems[position].text);
                tv.setCompoundDrawablesWithIntrinsicBounds(iconListItems[position].iconResId, 0, 0, 0);
                int padding = (int) (8 * getContext().getResources().getDisplayMetrics().density);
                tv.setCompoundDrawablePadding(padding);
            }
            return view;
        }
    };
    mListItemListener = listener;
}
 
Example 4
Source File: FileListView.java    From qplayer-sdk with MIT License 5 votes vote down vote up
private void initListView () {
    m_lvListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            SimpleAdapter adapter = (SimpleAdapter)m_lstFiles.getAdapter();
            Map<String, Object> map = (Map<String, Object>)adapter.getItem(position);
            String  strFile = (String) map.get("path");
            String	strDir = (String) map.get("dir");

            if (strDir.equals("1")) {
                updateFileList (strFile);
            } else {
                String strExt = strFile.substring(strFile.length() - 4);
                if (strExt.equalsIgnoreCase(".url")) {
                    updateURLList (strFile);
                } else {
                    Intent intent = new Intent(FileListView.this, PlayerView.class);
                    intent.setData(Uri.parse(strFile));
                    startActivity(intent);
                }
            }
        }
    };
    m_lstFiles = (ListView)findViewById (R.id.listViewFile);
    m_lstFiles.setOnItemClickListener(m_lvListener);
    m_txtURL = (EditText)findViewById (R.id.editTextURL);
    m_btnPlay = (Button)findViewById (R.id.buttonPlay);

    m_btnPlay.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        String strURL = m_txtURL.getText ().toString();
        Intent intent = new Intent(FileListView.this, PlayerView.class);
        intent.setData(Uri.parse(strURL));
        startActivity(intent);
        }
    });
}
 
Example 5
Source File: SimpleGridMenu.java    From hipda with GNU General Public License v2.0 4 votes vote down vote up
public void add(String actionKey, String actionName, AdapterView.OnItemClickListener listener) {
    add(actionKey, actionName, listener, null, null);
}
 
Example 6
Source File: PlacesAutocompleteTextView.java    From android-PlacesAutocompleteTextView with BSD 2-Clause "Simplified" License 4 votes vote down vote up
/**
 * DO NOT USE. Prefer {@link #setOnPlaceSelectedListener} instead
 */
@Override
public final void setOnItemClickListener(final AdapterView.OnItemClickListener l) {
    throw new UnsupportedOperationException("Use set" + OnPlaceSelectedListener.class.getSimpleName() + "() instead");
}
 
Example 7
Source File: NiceSpinner.java    From nice-spinner with Apache License 2.0 4 votes vote down vote up
/**
 * @deprecated use setOnSpinnerItemSelectedListener instead.
 */
@Deprecated
public void addOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
    this.onItemClickListener = onItemClickListener;
}
 
Example 8
Source File: BackupRestoreDialog.java    From narrate-android with Apache License 2.0 4 votes vote down vote up
public void setItemClickListener(AdapterView.OnItemClickListener itemClickListener) {
    this.itemClickListener = itemClickListener;
}
 
Example 9
Source File: PopWrapSharePlatformSelector.java    From BiliShare with Apache License 2.0 4 votes vote down vote up
public PopWrapSharePlatformSelector(FragmentActivity context, View anchorView, OnShareSelectorDismissListener dismissListener, AdapterView.OnItemClickListener itemClickListener) {
    super(context, dismissListener, itemClickListener);
    mAnchorView = anchorView;
}
 
Example 10
Source File: GraphView.java    From GraphView with Apache License 2.0 4 votes vote down vote up
public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
    graphNodeContainerView.setOnItemClickListener(onItemClickListener);
}
 
Example 11
Source File: DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void onItemClick(AdapterView.OnItemClickListener arg) {
  return BaseDSL.attr("onItemClick", arg);
}
 
Example 12
Source File: RecyclerViewHolder.java    From commonadapter with MIT License 4 votes vote down vote up
public RecyclerViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    mHolderImpl.setOnItemClickListener(viewId, listener);
    return this;
}
 
Example 13
Source File: IcsListPopupWindow.java    From CSipSimple with GNU General Public License v3.0 4 votes vote down vote up
public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) {
    mItemClickListener = clickListener;
}
 
Example 14
Source File: UltimateListview.java    From UltimateAndroid with Apache License 2.0 4 votes vote down vote up
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
    mBasicUltimateListView.setOnItemClickListener(listener);
}
 
Example 15
Source File: BottomSheetSpinnerDialog.java    From TwistyTimer with GNU General Public License v3.0 4 votes vote down vote up
public void setListClickListener(AdapterView.OnItemClickListener clickListener) {
    mClickListener = clickListener;
}
 
Example 16
Source File: BaseViewHolder.java    From NIM_Android_UIKit with MIT License 2 votes vote down vote up
/**
 * Sets the listview or gridview's item click listener of the view
 *
 * @param viewId   The view id.
 * @param listener The item on click listener;
 * @return The BaseViewHolder for chaining.
 */
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
Example 17
Source File: MaterialSearchView.java    From talk-android with MIT License 2 votes vote down vote up
/**
 * Set Suggest List OnItemClickListener
 *
 * @param listener
 */
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
    mSuggestionsListView.setOnItemClickListener(listener);
}
 
Example 18
Source File: ListPopupWindow.java    From MDPreference with Apache License 2.0 2 votes vote down vote up
/**
 * Sets a listener to receive events when a list item is clicked.
 *
 * @param clickListener Listener to register
 *
 * @see ListView#setOnItemClickListener(AdapterView.OnItemClickListener)
 */
public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) {
    mItemClickListener = clickListener;
}
 
Example 19
Source File: WithSpinnerTextView.java    From BigApp_Discuz_Android with Apache License 2.0 2 votes vote down vote up
/**
 * 设置Spinner 状态变更监听器
 *
 * @param l
 */
public void setOnItemClickListener(AdapterView.OnItemClickListener l) {
    spinner.setOnItemClickListener(l);
}
 
Example 20
Source File: AutoListView.java    From SweetMusicPlayer with Apache License 2.0 2 votes vote down vote up
/**
 * 没有header和footer的监听
 *
 * @param listener
 */
public void setOnItemNoneClickListener(AdapterView.OnItemClickListener listener) {
    this.mOnItemNoneClickListener = listener;
}