Example usage for android.view View setOnClickListener

List of usage examples for android.view View setOnClickListener

Introduction

In this page you can find the example usage for android.view View setOnClickListener.

Prototype

public void setOnClickListener(@Nullable OnClickListener l) 

Source Link

Document

Register a callback to be invoked when this view is clicked.

Usage

From source file:cm.aptoidetv.pt.ViewPagerAdapterScreenshots.java

@Override
public Object instantiateItem(ViewGroup container, final int position) {

    final View v = LayoutInflater.from(context).inflate(R.layout.row_item_screenshots_big, null);
    final ProgressBar pb = (ProgressBar) v.findViewById(R.id.screenshots_loading_big);

    String icon;/*  w w  w. j a v  a 2  s  . co m*/
    if (hd) {
        Log.d("Aptoide-Screenshots", "Icon is hd: " + url.get(position));

        if (url.get(position).contains("_screen")) {
            icon = url.get(position).split("\\|")[1];
            Log.d("Aptoide-Screenshots", "Icon is : " + icon);
        } else {
            icon = url.get(position);
        }

    } else {
        icon = screenshotToThumb(url.get(position));
    }

    Picasso.with(context).load(icon).error(R.drawable.icon_non_available)
            .into((ImageView) v.findViewById(R.id.screenshot_image_big));

    container.addView(v);
    if (!hd) {
        v.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {
                Intent i = new Intent(context, ScreenshotsViewer.class);
                i.putStringArrayListExtra("url", url);
                i.putExtra("position", position);
                context.startActivity(i);
            }
        });
    }
    return v;

}

From source file:bf.io.openshop.ux.MainActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_main, menu);

    // Prepare search view
    MenuItem searchItem = menu.findItem(R.id.action_search);
    if (searchItem != null) {
        prepareSearchView(searchItem);// w w w  .  ja  va  2  s .  co  m
    }

    // Prepare cart count info
    MenuItem cartItem = menu.findItem(R.id.action_cart);
    MenuItemCompat.setActionView(cartItem, R.layout.action_icon_shopping_cart);
    View view = MenuItemCompat.getActionView(cartItem);
    cartCountView = (TextView) view.findViewById(R.id.shopping_cart_notify);
    showNotifyCount(cartCountNotificationValue);
    view.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            onCartSelected();
        }
    });
    if (cartCountNotificationValue == CONST.DEFAULT_EMPTY_ID) {
        // If first cart count check, then sync server cart data.
        getCartCount(true);
    }
    return super.onCreateOptionsMenu(menu);
}

From source file:android.support.v7.app.AppCompatViewInflater.java

/**
 * android:onClick doesn't handle views with a ContextWrapper context. This method
 * backports new framework functionality to traverse the Context wrappers to find a
 * suitable target./*w w w . j a v  a2 s .co m*/
 */
private void checkOnClickListener(View view, AttributeSet attrs) {
    final Context context = view.getContext();

    if (!(context instanceof ContextWrapper)
            || (Build.VERSION.SDK_INT >= 15 && !ViewCompat.hasOnClickListeners(view))) {
        // Skip our compat functionality if: the Context isn't a ContextWrapper, or
        // the view doesn't have an OnClickListener (we can only rely on this on API 15+ so
        // always use our compat code on older devices)
        return;
    }

    final TypedArray a = context.obtainStyledAttributes(attrs, sOnClickAttrs);
    final String handlerName = a.getString(0);
    if (handlerName != null) {
        view.setOnClickListener(new DeclaredOnClickListener(view, handlerName));
    }
    a.recycle();
}

From source file:com.axum.darivb.searchview.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;/*from  w w w. j  a  v a 2 s  .  co  m*/

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        CharSequence title = adapter.getPageTitle(i);
        tabTitleView.setText(title);

        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:cn.androidy.pager.slidingtab.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;/* w ww  . j  ava2s .c  o m*/

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);
        mTabStrip.addView(tabView, dm.widthPixels / 4, (int) (42 * dm.density));
    }
}

From source file:adi.sf1.targaryen.newyorktimes.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final View.OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;/*from  ww w  .  ja  va2s.com*/

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:alvi17.mathformula.model.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;/*from   w ww. j  a va2  s . com*/

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.app.viewslider.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;//from  ww w.j a va2 s. c o m

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }
        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.ashish.routofy.PagerSlidingTabStrip.java

private void addTab(final int position, CharSequence title, View tabView) {
    TextView textView = (TextView) tabView.findViewById(R.id.psts_tab_title);
    if (textView != null) {
        if (title != null)
            textView.setText(title);//  ww w .jav  a2 s.c o m
    }

    tabView.setFocusable(true);
    tabView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            if (pager.getCurrentItem() != position) {
                View tab = tabsContainer.getChildAt(pager.getCurrentItem());
                notSelected(tab);
                pager.setCurrentItem(position);
            } else if (tabReselectedListener != null) {
                tabReselectedListener.onTabReselected(position);
            }
        }
    });

    tabsContainer.addView(tabView, position, shouldExpand ? expandedTabLayoutParams : defaultTabLayoutParams);
}

From source file:com.android.slidingtab.SlidingTabLayout.java

private void populateTabStrip() {
    final PagerAdapter adapter = mViewPager.getAdapter();
    final OnClickListener tabClickListener = new TabClickListener();

    for (int i = 0; i < adapter.getCount(); i++) {
        View tabView = null;
        TextView tabTitleView = null;/*w w  w.j  a  va 2  s .  c o  m*/

        if (mTabViewLayoutId != 0) {
            // If there is a custom tab view layout id set, try and inflate it
            tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false);
            tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }

        if (tabView == null) {
            tabView = createDefaultTabView(getContext());
        }

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }

        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addTabTitleView(tabTitleView);
        mTabStrip.addView(tabView);
    }
}