Example usage for android.widget ImageView setSelected

List of usage examples for android.widget ImageView setSelected

Introduction

In this page you can find the example usage for android.widget ImageView setSelected.

Prototype

@Override
    public void setSelected(boolean selected) 

Source Link

Usage

From source file:com.minnloft.checkmyfluids.tabs.SlidingTabLayout.java

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

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

        ImageView tabImageView = null;

        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);

            tabImageView = (ImageView) tabView.findViewById(mTabViewImageId);
        }

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

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

        if (tabImageView == null && ImageView.class.isInstance(tabView)) {
            tabImageView = (ImageView) tabView;
        }

        if (mDistributeEvenly) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            lp.width = 0;
            lp.weight = 1;
        }

        tabTitleView.setText(adapter.getPageTitle(i));

        //tabImageView.setImageResource(adapter.getImageId(i));
        tabImageView.setImageDrawable(getResources().getDrawable(adapter.getImageId(i)));
        if (mViewPager.getCurrentItem() == i) {
            tabImageView.setSelected(true);
        }

        tabView.setOnClickListener(tabClickListener);
        String desc = mContentDescriptions.get(i, null);
        if (desc != null) {
            tabView.setContentDescription(desc);
        }

        mTabStrip.addView(tabView);
        if (i == mViewPager.getCurrentItem()) {
            tabView.setSelected(true);
        }

        tabTitleView.setTextColor(getResources().getColorStateList(R.color.selector));

        //Change the font size
        tabTitleView.setTextSize(TAB_TEXT_SIZE);

        tabTitleView.setAllCaps(true);
    }
}

From source file:com.mad.umad.views.tab.SlidingTabLayout.java

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

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

        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);
            tabIconView = (ImageView) tabView.findViewById(R.id.tab_layout_icon);
            //                tabIconView.setLayoutParams(new LinearLayout.LayoutParams());
            //                tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId);
        }
        //
        //            if (tabView == null) {
        //                tabView = createDefaultTabView(getContext());
        //            }
        //
        //            if (tabTitleView == null && TextView.class.isInstance(tabView)) {
        //                tabTitleView = (TextView) tabView;
        //            }

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

        if (tabIconView == null && ImageView.class.isInstance(tabView)) {

            tabIconView = (ImageView) tabView;
        }

        Drawable temp = getResources().getDrawable(adapter.getDrawableId(i));

        tabIconView.setImageDrawable(temp);
        if (mViewPager.getCurrentItem() == i) {
            tabIconView.setSelected(true);
        }

        //tabTitleView.setText(adapter.getPageTitle(i));

        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.android.dialer.DialtactsFragment.java

/**
 * @author bbk wangchunhe/*  w w  w .  j  a v  a  2 s  . c  om*/
 * @Date 2016/07/15
 * add PopupWindow OnClickListener
 * @param popupWindow
 */
private void popupWindowItemSelect(final PopupWindow popupWindow) {
    View contentView = popupWindow.getContentView();
    RelativeLayout callLogsContainer = (RelativeLayout) contentView
            .findViewById(R.id.dialtacts_popupwindow_all_calls_cantainer);
    final TextView callLogsTxt = (TextView) contentView.findViewById(R.id.dialtacts_popupwindow_all_calls_txt);
    final ImageView callLogsImage = (ImageView) contentView
            .findViewById(R.id.dialtacts_popupwindow_all_calls_image);

    RelativeLayout callLogMissedContainer = (RelativeLayout) contentView
            .findViewById(R.id.dialtacts_popupwindow_call_log_missed_container);
    final TextView callLogMissedTxt = (TextView) contentView
            .findViewById(R.id.dialtacts_popupwindow_call_log_missed_txt);
    final ImageView callLogMissedImage = (ImageView) contentView
            .findViewById(R.id.dialtacts_popupwindow_call_log_missed_image);

    ColorStateList colorStateListTxt = getActivity().getColorStateList(R.color.popupwindows_item_text_color);
    ColorStateList colorStateListImage = getActivity().getColorStateList(R.color.popupwindows_item_image_color);

    callLogsImage.setImageTintList(colorStateListImage);
    callLogMissedImage.setImageTintList(colorStateListImage);

    callLogsTxt.setTextColor(colorStateListTxt);
    callLogMissedTxt.setTextColor(colorStateListTxt);

    if (!callLogMissedImage.isSelected()) {
        callLogsImage.setSelected(true);
        callLogsTxt.setSelected(true);
    }

    callLogsContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            callLogsImage.setSelected(true);
            callLogsTxt.setSelected(true);
            callLogMissedImage.setSelected(false);
            callLogMissedTxt.setSelected(false);
            showCallLogFragment(CallLogQueryHandler.CALL_TYPE_ALL);
            //                mActionbarNameTxt.setText(getString(R.string.all_calls));
            //                mDialtactsActionBarController.setActionNameAndMenu(R.string.all_calls,R.string.call_log_missed,R.string.select_call_log);
            Log.e(TAG, " action Name  --1" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mDialtactsActionBarController.setActionName(getString(R.string.all_calls));
            Log.e(TAG, " action Name  --2" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mCallLogSelectPopupWindow.dismiss();

        }
    });

    callLogMissedContainer.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            callLogsImage.setSelected(false);
            callLogsTxt.setSelected(false);
            callLogMissedImage.setSelected(true);
            callLogMissedTxt.setSelected(true);
            showCallLogFragment(Calls.MISSED_TYPE);
            //                mActionbarNameTxt.setText(getString(R.string.call_log_missed));
            //                mDialtactsActionBarController.setActionNameAndMenu(R.string.all_calls,R.string.call_log_missed,R.string.select_call_log);
            Log.e(TAG, " action Name  --3" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mDialtactsActionBarController.setActionName(getString(R.string.call_log_missed));
            Log.e(TAG, " action Name  --4" + mDialtactsActionBarController.getmActionNameTxt().getText());
            mCallLogSelectPopupWindow.dismiss();

        }
    });

}