public virtual void onItemClick(object parent, android.view.View view, int position , long id) { android.widget.ActivityChooserView.ActivityChooserViewAdapter adapter = (android.widget.ActivityChooserView .ActivityChooserViewAdapter)((android.widget.IAdapterView)parent).getAdapter(); int itemViewType = adapter.getItemViewType(position); switch (itemViewType) { case android.widget.ActivityChooserView.ActivityChooserViewAdapter.ITEM_VIEW_TYPE_FOOTER : { this._enclosing.showPopupUnchecked(android.widget.ActivityChooserView.ActivityChooserViewAdapter .MAX_ACTIVITY_COUNT_UNLIMITED); break; } case android.widget.ActivityChooserView.ActivityChooserViewAdapter.ITEM_VIEW_TYPE_ACTIVITY : { this._enclosing.dismissPopup(); if (this._enclosing.mIsSelectingDefaultActivity) { // The item at position zero is the default already. if (position > 0) { this._enclosing.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 = this._enclosing.mAdapter.getShowDefaultActivity() ? position : position + 1; android.content.Intent launchIntent = this._enclosing.mAdapter.getDataModel().chooseActivity (position); if (launchIntent != null) { this._enclosing.mContext.startActivity(launchIntent); } } break; } default: { throw new System.ArgumentException(); } } }
/// <summary>Create a new instance.</summary> /// <remarks>Create a new instance.</remarks> /// <param name="context">The application environment.</param> /// <param name="attrs">A collection of attributes.</param> /// <param name="defStyle">The default style to apply to this view.</param> public ActivityChooserView(android.content.Context context, android.util.AttributeSet attrs, int defStyle) : base(context, attrs, defStyle) { mModelDataSetOberver = new _DataSetObserver_118(this); mOnGlobalLayoutListener = new _OnGlobalLayoutListener_132(this); android.content.res.TypedArray attributesArray = context.obtainStyledAttributes(attrs , [email protected], defStyle, 0); mInitialActivityCount = attributesArray.getInt([email protected]_initialActivityCount , android.widget.ActivityChooserView.ActivityChooserViewAdapter.MAX_ACTIVITY_COUNT_DEFAULT ); android.graphics.drawable.Drawable expandActivityOverflowButtonDrawable = attributesArray .getDrawable([email protected]_expandActivityOverflowButtonDrawable ); attributesArray.recycle(); android.view.LayoutInflater inflater = android.view.LayoutInflater.from(mContext); inflater.inflate([email protected]_chooser_view, this, true); mCallbacks = new android.widget.ActivityChooserView.Callbacks(this); mActivityChooserContent = (android.widget.LinearLayout)findViewById([email protected] .id.activity_chooser_view_content); mActivityChooserContentBackground = mActivityChooserContent.getBackground(); mDefaultActivityButton = (android.widget.FrameLayout)findViewById([email protected] .id.default_activity_button); mDefaultActivityButton.setOnClickListener(mCallbacks); mDefaultActivityButton.setOnLongClickListener(mCallbacks); mDefaultActivityButtonImage = (android.widget.ImageView)mDefaultActivityButton.findViewById ([email protected]); mExpandActivityOverflowButton = (android.widget.FrameLayout)findViewById([email protected] .id.expand_activities_button); mExpandActivityOverflowButton.setOnClickListener(mCallbacks); mExpandActivityOverflowButtonImage = (android.widget.ImageView)mExpandActivityOverflowButton .findViewById([email protected]); mExpandActivityOverflowButtonImage.setImageDrawable(expandActivityOverflowButtonDrawable ); mAdapter = new android.widget.ActivityChooserView.ActivityChooserViewAdapter(this ); mAdapter.registerDataSetObserver(new _DataSetObserver_239(this)); android.content.res.Resources resources = context.getResources(); mListPopupMaxWidth = System.Math.Max(resources.getDisplayMetrics().widthPixels / 2, resources.getDimensionPixelSize([email protected]_prefDialogWidth )); }