List of usage examples for android.view View setOnClickListener
public void setOnClickListener(@Nullable OnClickListener l)
From source file:com.contentful.discovery.ui.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);/*from ww w .jav a 2 s. c o m*/ tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tab.setPadding(tabPadding, 0, tabPadding, 0); ViewGroup.LayoutParams params; if (shouldExpand) { params = expandedTabLayoutParams; } else { params = defaultTabLayoutParams; } tabsContainer.addView(tab, position, params); }
From source file:com.bilibili.boxing_impl.ui.BoxingViewFragment.java
public void setTitleTxt(TextView titleTxt) { mTitleTxt = titleTxt;/*from ww w.j a v a 2s . c o m*/ mTitleTxt.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mAlbumPopWindow == null) { int height = WindowManagerHelper.getScreenHeight(v.getContext()) - (WindowManagerHelper.getToolbarHeight(v.getContext()) + WindowManagerHelper.getStatusBarHeight(v.getContext())); View windowView = createWindowView(); mAlbumPopWindow = new PopupWindow(windowView, ViewGroup.LayoutParams.MATCH_PARENT, height, true); mAlbumPopWindow.setAnimationStyle(R.style.PopupAnimation); mAlbumPopWindow.setOutsideTouchable(true); mAlbumPopWindow.setBackgroundDrawable( new ColorDrawable(ContextCompat.getColor(v.getContext(), R.color.colorPrimaryAlpha))); mAlbumPopWindow.setContentView(windowView); } mAlbumPopWindow.showAsDropDown(v, 0, 0); } @NonNull private View createWindowView() { View view = LayoutInflater.from(getActivity()).inflate(R.layout.layout_album, null); RecyclerView recyclerView = (RecyclerView) view.findViewById(R.id.album_recycleview); recyclerView.setLayoutManager( new LinearLayoutManager(view.getContext(), LinearLayoutManager.VERTICAL, false)); recyclerView.addItemDecoration(new SpacesItemDecoration(2, 1)); View albumShadowLayout = view.findViewById(R.id.album_shadow); albumShadowLayout.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dismissAlbumWindow(); } }); mAlbumWindowAdapter.setAlbumOnClickListener(new OnAlbumItemOnClickListener()); recyclerView.setAdapter(mAlbumWindowAdapter); return view; } }); }
From source file:com.altitudelabs.swiftcart.view.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);// www .j a v a 2s . co m tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position); } }); tab.setPadding(getResources().getDimensionPixelSize(R.dimen.pager_tab_strip_tab_padding), 0, getResources().getDimensionPixelSize(R.dimen.pager_tab_strip_tab_padding), 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:org.elasticdroid.SshConnectorView.java
/** * Called when activity is created./* w ww.j a va 2 s . c om*/ * @param savedInstanceState if any */ @SuppressWarnings("unchecked") @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //call superclass onCreate Intent intent = this.getIntent(); //get all of the data stored in the intent try { this.connectionData = (HashMap<String, String>) intent .getSerializableExtra("org.elasticdroid.EC2DashboardView.connectionData"); } catch (Exception exception) { //the possible exceptions are NullPointerException: the Hashmap was not found, or //ClassCastException: the argument passed is not Hashmap<String, String>. In either case, //just print out the error and exit. This is very inelegant, but this is a programmer's bug Log.e(TAG, exception.getMessage()); finish(); //this will cause it to return to {@link EC2DisplayInstancesView}. } securityGroupNames = intent.getStringArrayExtra("securityGroups"); hostname = intent.getStringExtra("hostname"); selectedRegion = intent.getStringExtra("selectedRegion"); // create and initialise the alert dialog alertDialogBox = new AlertDialog.Builder(this).create(); // create alert alertDialogBox.setCancelable(false); alertDialogBox.setButton(this.getString(R.string.loginview_alertdialogbox_button), new DialogInterface.OnClickListener() { // click listener on the alert box - unlock orientation when // clicked. // this is to prevent orientation changing when alert box // locked. public void onClick(DialogInterface arg0, int arg1) { alertDialogDisplayed = false; alertDialogBox.dismiss(); // dismiss dialog. // if an error occurs that is serious enough return the // user to the login // screen. THis happens due to exceptions caused by // programming errors and // exceptions caused due to invalid credentials. if (killActivityOnError) { Log.v(TAG, "Ich bin hier."); SshConnectorView.this.finish(); } } }); //initialise the display setContentView(R.layout.sshconnector); //tell the activity to set the xml file this.setTitle(connectionData.get("username") + " (" + selectedRegion + ")"); //set title View loginButton = (View) this.findViewById(R.id.sshConnectorLoginButton); loginButton.setOnClickListener(this); }
From source file:com.aibasis.parent.widget.PagerSlidingTabStrip.java
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); ViewGroup tabViewGroup = getTabsLayout(); if (tabViewGroup != null) { // ?????//from w w w .ja va2 s . co m currentPosition = viewPager != null ? viewPager.getCurrentItem() : 0; if (!disableViewPager) { scrollToChild(currentPosition, 0); // ?? selectedTab(currentPosition); // ?TAB } // ?tab?Pager for (int w = 0; w < tabViewGroup.getChildCount(); w++) { View itemView = tabViewGroup.getChildAt(w); itemView.setTag(w); itemView.setOnClickListener(this); } } }
From source file:com.cc.digital.mylayout.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);//w w w . j a v a 2s. c o m tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Log.e("position:", "" + position); pager.setCurrentItem(position); } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:android.support.v7.internal.widget.ActionBarContextView.java
public void initForMode(final ActionMode mode) { if (mClose == null) { LayoutInflater inflater = LayoutInflater.from(getContext()); mClose = inflater.inflate(mCloseItemLayout, this, false); addView(mClose);//from w w w. ja va 2 s .c om } else if (mClose.getParent() == null) { addView(mClose); } View closeButton = mClose.findViewById(R.id.action_mode_close_button); closeButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { mode.finish(); } }); final MenuBuilder menu = (MenuBuilder) mode.getMenu(); if (mActionMenuPresenter != null) { mActionMenuPresenter.dismissPopupMenus(); } mActionMenuPresenter = new ActionMenuPresenter(getContext()); mActionMenuPresenter.setReserveOverflow(true); final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT); if (!mSplitActionBar) { menu.addMenuPresenter(mActionMenuPresenter, mPopupContext); mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); mMenuView.setBackgroundDrawable(null); addView(mMenuView, layoutParams); } else { // Allow full screen width in split mode. mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true); // No limit to the item count; use whatever will fit. mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE); // Span the whole width layoutParams.width = LayoutParams.MATCH_PARENT; layoutParams.height = mContentHeight; menu.addMenuPresenter(mActionMenuPresenter, mPopupContext); mMenuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this); mMenuView.setBackgroundDrawable(mSplitBackground); mSplitView.addView(mMenuView, layoutParams); } mAnimateInOnLayout = true; }
From source file:com.cs.widget.tab.PagerSlidingTabStrip.java
private void addTab(final int position, View tab) { tab.setFocusable(true);//w w w .j a v a 2 s . c om tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { pager.setCurrentItem(position, true); } }); tab.setPadding(tabPadding, 0, tabPadding, 0); tabsContainer.addView(tab, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams); }
From source file:com.cicada.yuanxiaobao.common.BaseAdapterHelper.java
/** * Sets the on click listener of the view. * //w w w . jav a 2s .com * @param viewId * The view id. * @param listener * The on click listener; * @return The BaseAdapterHelper for chaining. */ public BaseAdapterHelper setOnClickListener(int viewId, ParentsPhonePopupAdapter listener) { View view = retrieveView(viewId); view.setOnClickListener(listener); return this; }
From source file:com.astuetz.viewpager.extensions.SwipeyTabsView.java
/** * Adds a new {@link SwipeyTabButton} to the layout * * @param index The index from the Pagers adapter * @param title The title which should be used *///from ww w. j ava 2 s. c o m public void addTab(View tab, final int index) { if (tab == null) return; addView(tab); tab.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { mPager.setCurrentItem(index); } }); tab.setOnTouchListener(this); }