當前位置: 首頁>>代碼示例>>Java>>正文


Java AdapterView.OnItemClickListener方法代碼示例

本文整理匯總了Java中android.widget.AdapterView.OnItemClickListener方法的典型用法代碼示例。如果您正苦於以下問題:Java AdapterView.OnItemClickListener方法的具體用法?Java AdapterView.OnItemClickListener怎麽用?Java AdapterView.OnItemClickListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.widget.AdapterView的用法示例。


在下文中一共展示了AdapterView.OnItemClickListener方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: newListener

import android.widget.AdapterView; //導入方法依賴的package包/類
private AdapterView.OnItemClickListener newListener() {
  return new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View v, int x, long id) {
      TextView t = (TextView)v;
      uri = (Uri)t.getTag();
      title = t.getText().toString();
      ((TextView)getDialog().findViewById(R.id.selected))
        .setText(getString(R.string.selected) + title);

      player.reset();
      try {
        player.setDataSource(getContext(), uri);
        player.prepare();
      } catch (IOException e) {
        Log.e(TAG, "Failed to set data " + e);
      }
      player.start();
    }
  };
}
 
開發者ID:sdrausty,項目名稱:buildAPKsApps,代碼行數:22,代碼來源:MediaPicker.java

示例2: onCreateView

import android.widget.AdapterView; //導入方法依賴的package包/類
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home, container, false);

    AdapterView.OnItemClickListener listener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            TwitchChannel channel = (TwitchChannel)arg0.getItemAtPosition(position);

            ChannelFragment fragment = new ChannelFragment();

            Bundle bundle = new Bundle();
            bundle.putString("channel", channel.username);

            fragment.setArguments(bundle);
            getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).addToBackStack(null).commit();
        }
    };

    final ListView onlineList = view.findViewById(R.id.online_channels);
    onlineList.setOnItemClickListener(listener);

    final ListView hostingList = view.findViewById(R.id.hosting_channels);
    hostingList.setOnItemClickListener(listener);

    final ListView offlineList = view.findViewById(R.id.offline_channels);
    offlineList.setOnItemClickListener(listener);

    return view;
}
 
開發者ID:invghost,項目名稱:NeoStream,代碼行數:32,代碼來源:HomeFragment.java

示例3: setItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
public WCBMenu setItemClickListener(AdapterView.OnItemClickListener listener) {
    mOnItemClickListener = listener;
    if (mBuilder != null) {
        mBuilder.setItemClickListener(listener);
    }
    return this;
}
 
開發者ID:gaelthas,項目名稱:WCBMenu,代碼行數:8,代碼來源:WCBMenu.java

示例4: initList

import android.widget.AdapterView; //導入方法依賴的package包/類
private void initList(){

        // Create the adpater only if null, This is here so we wont override the adapter given from the extended class with setAdapter.
        if (adapter == null)
            adapter = new ChatSDKThreadsListAdapter(getActivity());

        listThreads.setAdapter(adapter);

        if (onItemClickListener==null)
        {
            onItemClickListener = new AdapterView.OnItemClickListener() {
                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    startChatActivityForID(adapter.getItem(position).getId());
                }
            };
        }

        listThreads.setOnItemClickListener(onItemClickListener);

        if (onItemLongClickListener== null)
        {
            onItemLongClickListener = new AdapterView.OnItemLongClickListener() {
                @Override
                public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                    showAlertDialog("", getResources().getString(R.string.alert_delete_thread), getResources().getString(R.string.delete),
                            getResources().getString(R.string.cancel), null, new DeleteThread(adapter.getItem(position).getEntityId()));

                    return true;
                }
            };
        }

        listThreads.setOnItemLongClickListener(onItemLongClickListener);
    }
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:36,代碼來源:ChatSDKAbstractConversationsFragment.java

示例5: setItemsWithoutChk

import android.widget.AdapterView; //導入方法依賴的package包/類
public void setItemsWithoutChk(CharSequence[] items,
                               AdapterView.OnItemClickListener onItemClickListener) {
    ListView listview = new ListView(content.getContext());
    listview.setLayoutParams(new FrameLayout.LayoutParams(-1, -2));
    DialogAdapter adapter = new DialogAdapter(items);
    adapter.setShowChk(false);
    listview.setDivider(null);
    listview.setAdapter(adapter);
    listview.setOnItemClickListener(onItemClickListener);
    setContent(listview, 0);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:12,代碼來源:CommonDialog.java

示例6: initAdapter

import android.widget.AdapterView; //導入方法依賴的package包/類
private void initAdapter() {
    listAdapter = new TAdapter<>(context, itemTextList, new TAdapterDelegate() {
        @Override
        public int getViewTypeCount() {
            return itemTextList.size();
        }

        @Override
        public Class<? extends TViewHolder> viewHolderAtPosition(int position) {
            return MultiSelectDialogViewHolder.class;
        }

        @Override
        public boolean enabled(int position) {
            return true;
        }
    });
    itemListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            itemTextList.set(position,new Pair<String, Boolean>(itemTextList.get(position).first,!itemTextList.get(position).second));
            boolean hasChecked = false;
            for(Pair<String, Boolean> pair:itemTextList) {
                if(pair.second == true) {
                    hasChecked = true;
                }
            }
            positiveBtn.setEnabled(hasChecked);
            listAdapter.notifyDataSetChanged();
        }
    };
}
 
開發者ID:newDeepLearing,項目名稱:decoy,代碼行數:33,代碼來源:MultiSelectDialog.java

示例7: BaseRecyclerAdapter

import android.widget.AdapterView; //導入方法依賴的package包/類
public BaseRecyclerAdapter(Collection<T> collection, @LayoutRes int layoutId, AdapterView.OnItemClickListener listener) {
    setHasStableIds(false);
    setOnItemClickListener(listener);
    this.mList = new ArrayList<>(collection);
    this.mLayoutId = layoutId;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:BaseRecyclerAdapter.java

示例8: setOnItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
/**
 * DO NOT USE. Prefer {@link #setOnAddressSelectedListener} instead
 */
@Override
public final void setOnItemClickListener(final AdapterView.OnItemClickListener l) {
    throw new UnsupportedOperationException("Use set" + OnAddressSelectedListener.class.getSimpleName() + "() instead");
}
 
開發者ID:RacZo,項目名稱:Smarty-Streets-AutoCompleteTextView,代碼行數:8,代碼來源:SmartyStreetsAutocompleteTextView.java

示例9: setOnItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
	getListView().setOnItemClickListener(listener);
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:4,代碼來源:PullToRefreshEmptyAdapter.java

示例10: setListener

import android.widget.AdapterView; //導入方法依賴的package包/類
public void setListener(AdapterView.OnItemClickListener listener)
{
    this.listener = listener;
}
 
開發者ID:icaynia,項目名稱:pracler,代碼行數:5,代碼來源:MenuSelecter.java

示例11: getItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
private AdapterView.OnItemClickListener getItemClickListener(){
    return new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int position, long id) {
            final Intent intent = new Intent();

            showProgDialog("Opening thread.");

            getNetworkAdapter().createThreadWithUsers("", contactsFragment.getAdapter().getItem(position).asBUser(), getNetworkAdapter().currentUserModel())
                    .done(new DoneCallback<BThread>() {
                        @Override
                        public void onDone(final BThread thread) {
                            if (thread == null) {
                                if (DEBUG) Timber.e("thread added is null");
                                return;
                            }

                            if (isOnMainThread()) {
                                intent.putExtra(THREAD_ID, thread.getId());
                                setResult(RESULT_OK, intent);
                                finish();
                            } else
                                ChatSDKThreadDetailsActivity.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        intent.putExtra(THREAD_ID, thread.getId());
                                        setResult(RESULT_OK, intent);
                                        finish();
                                    }
                                });
                        }
                    })
                    .fail(new FailCallback<BError>() {
                        @Override
                        public void onFail(BError error) {
                            if (isOnMainThread()) {
                                showAlertToast(getString(R.string.create_thread_with_users_fail_toast));
                                dismissProgDialog();
                            } else
                                ChatSDKThreadDetailsActivity.this.runOnUiThread(new Runnable() {
                                    @Override
                                    public void run() {
                                        showAlertToast(getString(R.string.create_thread_with_users_fail_toast));
                                        dismissProgDialog();
                                    }
                                });
                        }
                    });
        }
    };
}
 
開發者ID:MobileDev418,項目名稱:chat-sdk-android-push-firebase,代碼行數:52,代碼來源:ChatSDKThreadDetailsActivity.java

示例12: setOnItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
public void setOnItemClickListener(AdapterView.OnItemClickListener onItemClickListener) {
    this.onItemClickListener = onItemClickListener;
}
 
開發者ID:NICOLITE,項目名稱:HutHelper,代碼行數:4,代碼來源:MenuAdapter.java

示例13: showChooseDialog

import android.widget.AdapterView; //導入方法依賴的package包/類
public void showChooseDialog(String title, List<String> list, AdapterView.OnItemClickListener listener) {
    ListView view = (ListView) getLayoutInflater().inflate(R.layout.base_dialog_list, null);
    view.setAdapter(new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, list));
    view.setOnItemClickListener(listener);
    mBaseDialog.setDialogContentView(view).setTitle(title).setBottomLayoutVisible(false).show();
}
 
開發者ID:HelloChenJinJun,項目名稱:TestChat,代碼行數:7,代碼來源:BaseActivity.java

示例14: setOnItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
@Override
public void setOnItemClickListener(AdapterView.OnItemClickListener listener) {
    mOnItemClicked = listener;
}
 
開發者ID:abook23,項目名稱:godlibrary,代碼行數:5,代碼來源:HorizontalListView.java

示例15: setOnItemClickListener

import android.widget.AdapterView; //導入方法依賴的package包/類
/**
 * 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.
 * Please use {@link #addOnClickListener(int)} (int)} (adapter.setOnItemChildClickListener(listener))}
 */
@Deprecated
public BaseViewHolder setOnItemClickListener(int viewId, AdapterView.OnItemClickListener listener) {
    AdapterView view = getView(viewId);
    view.setOnItemClickListener(listener);
    return this;
}
 
開發者ID:liu-xiao-dong,項目名稱:JD-Test,代碼行數:15,代碼來源:BaseViewHolder.java


注:本文中的android.widget.AdapterView.OnItemClickListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。