Java Code Examples for android.widget.AdapterView#getAdapter()
The following examples show how to use
android.widget.AdapterView#getAdapter() .
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: CommentsItemClickListener.java From YiBo with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); comment = (Comment)adapter.getItem(position); if (comment == null || (comment instanceof LocalComment && ((LocalComment)comment).isDivider())) { return; } if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter(); } CacheAdapter<Comment> cacheAdapter = (CacheAdapter<Comment>)adapter; Dialog dialog = onCreateDialog(cacheAdapter, position); if (dialog != null) { dialog.show(); } }
Example 2
Source File: DirectMessagesItemClickListener.java From YiBo with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); message = (DirectMessage)adapter.getItem(position); if (message == null || (message instanceof LocalDirectMessage && ((LocalDirectMessage)message).isDivider())) { return; } if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter(); } CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>)adapter; Dialog dialog = onCreateDialog(cacheAdapter, position); if (dialog != null) { dialog.show(); } }
Example 3
Source File: ConversationItemClickListener.java From YiBo with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); message = (DirectMessage)adapter.getItem(position); if (message == null || (message instanceof LocalDirectMessage && ((LocalDirectMessage)message).isDivider())) { return; } if (adapter instanceof HeaderViewListAdapter) { adapter = ((HeaderViewListAdapter)adapter).getWrappedAdapter(); } CacheAdapter<DirectMessage> cacheAdapter = (CacheAdapter<DirectMessage>)adapter; Dialog dialog = onCreateDialog(cacheAdapter, position); if (dialog != null) { dialog.show(); } }
Example 4
Source File: ZSwipeItem.java From ZListVIew with Apache License 2.0 | 6 votes |
/** * if working in {@link android.widget.AdapterView}, we should response * {@link android.widget.Adapter} isEnable(int position). * * @return true when item is enabled, else disabled. */ private boolean isEnabledInAdapterView() { @SuppressWarnings("rawtypes") AdapterView adapterView = getAdapterView(); boolean enable = true; if (adapterView != null) { Adapter adapter = adapterView.getAdapter(); if (adapter != null) { int p = adapterView.getPositionForView(ZSwipeItem.this); if (adapter instanceof BaseAdapter) { enable = ((BaseAdapter) adapter).isEnabled(p); } else if (adapter instanceof ListAdapter) { enable = ((ListAdapter) adapter).isEnabled(p); } } } return enable; }
Example 5
Source File: PinnedHeaderListView.java From Yahala-Messenger with MIT License | 6 votes |
@Override public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) { SectionedBaseAdapter adapter; if (adapterView.getAdapter() instanceof HeaderViewListAdapter) { HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter(); adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter(); } else { adapter = (SectionedBaseAdapter) adapterView.getAdapter(); } int section = adapter.getSectionForPosition(rawPosition); int position = adapter.getPositionInSectionForPosition(rawPosition); if (position == -1) { onSectionClick(adapterView, view, section, id); } else { onItemClick(adapterView, view, section, position, id); } }
Example 6
Source File: SwipeLayout.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * if working in {@link android.widget.AdapterView}, we should response * {@link android.widget.Adapter} isEnable(int position). * * @return true when item is enabled, else disabled. */ private boolean isEnabledInAdapterView() { AdapterView adapterView = getAdapterView(); boolean enable = true; if (adapterView != null) { Adapter adapter = adapterView.getAdapter(); if (adapter != null) { int p = adapterView.getPositionForView(SwipeLayout.this); if (adapter instanceof BaseAdapter) { enable = ((BaseAdapter) adapter).isEnabled(p); } else if (adapter instanceof ListAdapter) { enable = ((ListAdapter) adapter).isEnabled(p); } } } return enable; }
Example 7
Source File: PinnedHeaderListView.java From FoodOrdering with Apache License 2.0 | 6 votes |
@Override public void onItemClick(AdapterView<?> adapterView, View view, int rawPosition, long id) { SectionedBaseAdapter adapter; if (adapterView.getAdapter().getClass().equals(HeaderViewListAdapter.class)) { HeaderViewListAdapter wrapperAdapter = (HeaderViewListAdapter) adapterView.getAdapter(); adapter = (SectionedBaseAdapter) wrapperAdapter.getWrappedAdapter(); } else { adapter = (SectionedBaseAdapter) adapterView.getAdapter(); } int section = adapter.getSectionForPosition(rawPosition); int position = adapter.getPositionInSectionForPosition(rawPosition); if (position == -1) { onSectionClick(adapterView, view, section, id); } else { onItemClick(adapterView, view, section, position, id); } }
Example 8
Source File: SwipeLayout.java From UltimateAndroid with Apache License 2.0 | 6 votes |
/** * if working in {@link android.widget.AdapterView}, we should response {@link android.widget.Adapter} * isEnable(int position). * @return true when item is enabled, else disabled. */ private boolean isEnabledInAdapterView(){ AdapterView adapterView = getAdapterView(); boolean enable = true; if(adapterView != null){ Adapter adapter = adapterView.getAdapter(); if(adapter != null){ int p = adapterView.getPositionForView(SwipeLayout.this); if(adapter instanceof BaseAdapter){ enable = ((BaseAdapter) adapter).isEnabled(p); }else if(adapter instanceof ListAdapter){ enable = ((ListAdapter) adapter).isEnabled(p); } } } return enable; }
Example 9
Source File: AppWidgetHostView.java From android_9.0.0_r45 with Apache License 2.0 | 6 votes |
/** * Process data-changed notifications for the specified view in the specified * set of {@link RemoteViews} views. */ void viewDataChanged(int viewId) { View v = findViewById(viewId); if ((v != null) && (v instanceof AdapterView<?>)) { AdapterView<?> adapterView = (AdapterView<?>) v; Adapter adapter = adapterView.getAdapter(); if (adapter instanceof BaseAdapter) { BaseAdapter baseAdapter = (BaseAdapter) adapter; baseAdapter.notifyDataSetChanged(); } else if (adapter == null && adapterView instanceof RemoteAdapterConnectionCallback) { // If the adapter is null, it may mean that the RemoteViewsAapter has not yet // connected to its associated service, and hence the adapter hasn't been set. // In this case, we need to defer the notify call until it has been set. ((RemoteAdapterConnectionCallback) adapterView).deferNotifyDataSetChanged(); } } }
Example 10
Source File: ActivityChooserView.java From Libraries-for-Android-Developers with MIT License | 5 votes |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter(); final int itemViewType = adapter.getItemViewType(position); switch (itemViewType) { case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: { showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED); } break; case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: { dismissPopup(); if (mIsSelectingDefaultActivity) { // The item at position zero is the default already. if (position > 0) { mAdapter.getDataModel().setDefaultActivity(position); } } else { // If the default target is not shown in the list, the first // item in the model is default action => adjust index position = mAdapter.getShowDefaultActivity() ? position : position + 1; Intent launchIntent = mAdapter.getDataModel().chooseActivity(position); if (launchIntent != null) { mContext.startActivity(launchIntent); } } } break; default: throw new IllegalArgumentException(); } }
Example 11
Source File: IndexAdapter.java From SearchBarView with Apache License 2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if( listener != null ) { // 屏蔽 Index 的点击事件,只响应正常 item 的点击事件 Object adapter = parent.getAdapter(); if( adapter instanceof IndexAdapter<?> ) { IndexAdapter<?> indexAdapter = (IndexAdapter<?>) adapter; if( indexAdapter.getItemType(position) == ViewType.normal) { listener.onItemClick(parent, view, position, id); } } } }
Example 12
Source File: GlobalOnItemClickManagerUtils.java From chatui with Apache License 2.0 | 5 votes |
public AdapterView.OnItemClickListener getOnItemClickListener() { return new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Object itemAdapter = parent.getAdapter(); if (itemAdapter instanceof EmotionGridViewAdapter) { // 点击的是表情 EmotionGridViewAdapter emotionGvAdapter = (EmotionGridViewAdapter) itemAdapter; if (position == emotionGvAdapter.getCount() - 1) { // 如果点击了最后一个回退按钮,则调用删除键事件 mEditText.dispatchKeyEvent(new KeyEvent( KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL)); } else { // 如果点击了表情,则添加到输入框中 String emotionName = emotionGvAdapter.getItem(position); // 获取当前光标位置,在指定位置上添加表情图片文本 int curPosition = mEditText.getSelectionStart(); StringBuilder sb = new StringBuilder(mEditText.getText().toString()); sb.insert(curPosition, emotionName); // 特殊文字处理,将表情等转换一下 mEditText.setText(Utils.getEmotionContent(mContext, mEditText, sb.toString())); // 将光标设置到新增完表情的右侧 mEditText.setSelection(curPosition + emotionName.length()); } } } }; }
Example 13
Source File: MaterialRippleLayout.java From material-ripple with Apache License 2.0 | 5 votes |
private void clickAdapterView(AdapterView parent) { final int position = parent.getPositionForView(MaterialRippleLayout.this); final long itemId = parent.getAdapter() != null ? parent.getAdapter().getItemId(position) : 0; if (position != AdapterView.INVALID_POSITION) { parent.performItemClick(MaterialRippleLayout.this, position, itemId); } }
Example 14
Source File: ActivityChooserView.java From android-apps with MIT License | 5 votes |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter(); final int itemViewType = adapter.getItemViewType(position); switch (itemViewType) { case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: { showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED); } break; case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: { dismissPopup(); if (mIsSelectingDefaultActivity) { // The item at position zero is the default already. if (position > 0) { mAdapter.getDataModel().setDefaultActivity(position); } } else { // If the default target is not shown in the list, the first // item in the model is default action => adjust index position = mAdapter.getShowDefaultActivity() ? position : position + 1; Intent launchIntent = mAdapter.getDataModel().chooseActivity(position); if (launchIntent != null) { mContext.startActivity(launchIntent); } } } break; default: throw new IllegalArgumentException(); } }
Example 15
Source File: ActivityChooserView.java From zhangshangwuda with Apache License 2.0 | 5 votes |
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { ActivityChooserViewAdapter adapter = (ActivityChooserViewAdapter) parent.getAdapter(); final int itemViewType = adapter.getItemViewType(position); switch (itemViewType) { case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER: { showPopupUnchecked(ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_UNLIMITED); } break; case ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY: { dismissPopup(); if (mIsSelectingDefaultActivity) { // The item at position zero is the default already. if (position > 0) { mAdapter.getDataModel().setDefaultActivity(position); } } else { // If the default target is not shown in the list, the first // item in the model is default action => adjust index position = mAdapter.getShowDefaultActivity() ? position : position + 1; Intent launchIntent = mAdapter.getDataModel().chooseActivity(position); if (launchIntent != null) { mContext.startActivity(launchIntent); } } } break; default: throw new IllegalArgumentException(); } }
Example 16
Source File: RippleLayout.java From fingerpoetry-android with Apache License 2.0 | 5 votes |
private void clickAdapterView(AdapterView parent) { final int position = parent.getPositionForView(RippleLayout.this); final long itemId = parent.getAdapter() != null ? parent.getAdapter().getItemId(position) : 0; if (position != AdapterView.INVALID_POSITION) { parent.performItemClick(RippleLayout.this, position, itemId); } }
Example 17
Source File: MicroBlogItemClickListener.java From YiBo with Apache License 2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); Status status = (Status)adapter.getItem(position); if (status == null || (status instanceof LocalStatus && ((LocalStatus)status).isDivider())) { return; } Intent intent = new Intent(); Bundle bundle = new Bundle(); bundle.putSerializable("STATUS", status); CacheAdapter<?> cacheAdapter = AdapterUtil.getCacheAdapter(adapter); if (cacheAdapter instanceof MyHomeListAdapter) { bundle.putInt("SOURCE", Constants.REQUEST_CODE_MY_HOME); bundle.putInt("POSITION", position - 1); } intent.putExtras(bundle); intent.setClass(parent.getContext(), MicroBlogActivity.class); ((Activity)context).startActivityForResult(intent, Constants.REQUEST_CODE_MICRO_BLOG); CompatibilityUtil.overridePendingTransition( (Activity)context, R.anim.slide_in_right, android.R.anim.fade_out ); }
Example 18
Source File: SettingsListFragment.java From opentasks with Apache License 2.0 | 5 votes |
@Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long rowId) { VisibleListAdapter adapter = (VisibleListAdapter) adapterView.getAdapter(); VisibleListAdapter.CheckableItem item = (VisibleListAdapter.CheckableItem) view.getTag(); boolean checked = item.coloredCheckBox.isChecked(); item.coloredCheckBox.setChecked(!checked); adapter.addToState(rowId, !checked); }
Example 19
Source File: AppGridItemClickListener.java From YiBo with Apache License 2.0 | 4 votes |
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Adapter adapter = parent.getAdapter(); long appImageId = adapter.getItemId(position); Activity context = (Activity)parent.getContext(); Intent intent = new Intent(); if (appImageId == R.drawable.icon_app_search) { intent.setClass(context, SearchActivity.class); } else if (appImageId == R.drawable.icon_app_public_timeline) { intent.setClass(context, PublicTimelineActivity.class); } else if (appImageId == R.drawable.icon_app_hot_retweet) { intent.setClass(context, HotStatusesActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Retweet.getCatalogNo()); } else if (appImageId == R.drawable.icon_app_hot_comment) { intent.setClass(context, HotStatusesActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Hot_Comment.getCatalogNo()); } else if (appImageId == R.drawable.icon_app_hot_topic) { //intent.setClass(context, HotTopicsActivity.class); intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture_Mobile.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_hot_topic); } else if (appImageId == R.drawable.icon_app_daily) { intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.News.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_daily); } else if (appImageId == R.drawable.icon_app_image) { intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Picture.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_image); } else if (appImageId == R.drawable.icon_app_jokes) { intent.setClass(context, StatusSubscribeActivity.class); intent.putExtra("STATUS_CATALOG", StatusCatalog.Joke.getCatalogNo()); intent.putExtra("TITLE_ID", R.string.label_app_jokes); } else if (appImageId == R.drawable.icon_app_exchange) { ConfigSystemDao configDao = new ConfigSystemDao(context); String username = configDao.getString(Constants.PASSPORT_USERNAME); // if (StringUtil.isEmpty(username)) { // AppConnect.getInstance(context).showOffers(context); // } else { // AppConnect.getInstance(context).showOffers(context, username); // } return; } else { Toast.makeText(context, "抱歉,此功能正在开发中..", Toast.LENGTH_LONG).show(); return; } context.startActivity(intent); }
Example 20
Source File: PXAdapterInvocationHandler.java From pixate-freestyle-android with Apache License 2.0 | 2 votes |
/** * Creates a new proxied instance of the given adapter. * * @param obj An {@link AdapterView} instance. The proxy will be made for * its {@link Adapter}. * @param adapterInterfaces The interfaces that will be implemented on the * fly by the proxy * @return A new proxy for the {@link Adapter} */ public static Object newInstance(AdapterView<Adapter> adapterView, Class<?>[] adapterInterfaces) { Adapter adapter = adapterView.getAdapter(); return java.lang.reflect.Proxy.newProxyInstance(adapter.getClass().getClassLoader(), adapterInterfaces, new PXAdapterInvocationHandler(adapterView)); }