Java Code Examples for android.widget.AdapterView#OnItemClickListener

The following examples show how to use android.widget.AdapterView#OnItemClickListener . These examples are extracted from open source projects. 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 Project: biermacht   File: EditHopActivity.java    License: 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
@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
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 Project: qplayer-sdk   File: FileListView.java    License: 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
public void setListClickListener(AdapterView.OnItemClickListener clickListener) {
    mClickListener = clickListener;
}
 
Example 6
public void add(String actionKey, String actionName, AdapterView.OnItemClickListener listener) {
    add(actionKey, actionName, listener, null, null);
}
 
Example 7
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
    mBasicUltimateListView.setOnItemClickListener(listener);
}
 
Example 8
public void setOnItemClickListener(AdapterView.OnItemClickListener clickListener) {
    mItemClickListener = clickListener;
}
 
Example 9
Source Project: commonadapter   File: RecyclerViewHolder.java    License: MIT License 4 votes vote down vote up
public RecyclerViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    mHolderImpl.setOnItemClickListener(viewId, listener);
    return this;
}
 
Example 10
Source Project: anvil   File: DSL.java    License: MIT License 4 votes vote down vote up
public static Void onItemClick(AdapterView.OnItemClickListener arg) {
  return BaseDSL.attr("onItemClick", arg);
}
 
Example 11
Source Project: GraphView   File: GraphView.java    License: Apache License 2.0 4 votes vote down vote up
public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
    graphNodeContainerView.setOnItemClickListener(onItemClickListener);
}
 
Example 12
public PopWrapSharePlatformSelector(FragmentActivity context, View anchorView, OnShareSelectorDismissListener dismissListener, AdapterView.OnItemClickListener itemClickListener) {
    super(context, dismissListener, itemClickListener);
    mAnchorView = anchorView;
}
 
Example 13
public void setItemClickListener(AdapterView.OnItemClickListener itemClickListener) {
    this.itemClickListener = itemClickListener;
}
 
Example 14
Source Project: nice-spinner   File: NiceSpinner.java    License: 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 15
/**
 * 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 16
Source Project: NIM_Android_UIKit   File: BaseViewHolder.java    License: 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 Project: talk-android   File: MaterialSearchView.java    License: 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 Project: MDPreference   File: ListPopupWindow.java    License: 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
/**
 * 设置Spinner 状态变更监听器
 *
 * @param l
 */
public void setOnItemClickListener(AdapterView.OnItemClickListener l) {
    spinner.setOnItemClickListener(l);
}
 
Example 20
Source Project: SweetMusicPlayer   File: AutoListView.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * 没有header和footer的监听
 *
 * @param listener
 */
public void setOnItemNoneClickListener(AdapterView.OnItemClickListener listener) {
    this.mOnItemNoneClickListener = listener;
}