Example usage for android.widget TextView setSelected

List of usage examples for android.widget TextView setSelected

Introduction

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

Prototype

@Override
    public void setSelected(boolean selected) 

Source Link

Usage

From source file:github.changweitu.com.an.view.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;/*ww  w.  j a v  a  2s . co  m*/
        TextView tabTitleView = 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);
        }

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

        if (tabTitleView == null && TextView.class.isInstance(tabView)) {
            tabTitleView = (TextView) tabView;
        }
        if (mDistributeEvenly) {
            LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) tabView.getLayoutParams();
            layoutParams.width = 0;
            layoutParams.weight = 1;
        }
        tabTitleView.setText(adapter.getPageTitle(i));
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            tabTitleView.setTextColor(getResources().getColorStateList(R.color.sliding_tab_text_color, null));
        } else {
            tabTitleView.setTextColor(getResources().getColorStateList(R.color.sliding_tab_text_color));
        }
        tabTitleView.setTextSize(14);
        if (i == mViewPager.getCurrentItem()) {
            tabTitleView.setSelected(true);
        }
        tabView.setOnClickListener(tabClickListener);

        mTabStrip.addView(tabView);
    }
}

From source file:com.tekinarslan.material.sample.customui.slidingtab_new.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;/*from  w w w  . j  a v a2  s.c o  m*/
        TextView tabTitleView = 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);
        }

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

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

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

        tabTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TExt_Text_Size);
        tabTitleView.setText(adapter.getPageTitle(i));
        tabView.setOnClickListener(tabClickListener);

        //         tabTitleView.setTextColor(TITLE_TEXT_DEFAULT_COLOR);
        //         tabTitleView.setTextColor(R.drawable.xpt_qfmycollection_tab_title_text);
        tabTitleView.setSelected(false);
        if (i == 0) {
            tabTitleView.setTextColor(TITLE_TEXT_SELECTED_COLOR);
            //            tabTitleView.setSelected(true);
        }

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

        if (lockedWidth) {
            // ?
            int tabWidth = viewWidth / mViewPager.getAdapter().getCount();//?
            //                int tabWidth = tabView.getWidth();
            //                LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(tabWidth, LayoutParams.WRAP_CONTENT);
            LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
                    LayoutParams.WRAP_CONTENT);
            //                params.weight=1;
            //                params.width=0;
            mTabStrip.addView(tabView, params);
            LogUtils.d("tabViewWidth  " + tabView.getWidth() + "  tabWidth  " + tabWidth + "  tabTitleView "
                    + tabTitleView.getText() + "  tabTitleView.width " + tabTitleView.getWidth());

        } else {
            LogUtils.d("tabView  " + tabView);
            mTabStrip.addView(tabView);
        }
    }

}

From source file:com.silentcircle.silentphone2.dialogs.CryptoInfoDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mParent);
    // Get the layout inflater
    LayoutInflater inflater = mParent.getLayoutInflater();

    CallState call = TiviPhoneService.calls.selectedCall;
    if (call == null)
        return null;

    String buildInfo = TiviPhoneService.getInfo(call.iEngID, call.iCallId, lbBuildInfo);
    if (ConfigurationUtilities.mTrace)
        Log.d(TAG, "ZRTP build information: " + buildInfo);

    // Inflate and set the layout for the dialog
    // set the SAS string to compare
    // Pass null as the parent view because its going in the dialog layout
    View view = inflater.inflate(R.layout.dialog_crypto_info, null, false);
    if (view == null)
        return null;

    TextView txtView = (TextView) view.findViewById(R.id.CryptoCryptoComponentsCipherInfo);
    txtView.setText(TiviPhoneService.getInfo(-1, call.iCallId, lbCipher));

    txtView = (TextView) view.findViewById(R.id.CryptoCryptoComponentsHashInfo);
    txtView.setText(TiviPhoneService.getInfo(call.iEngID, call.iCallId, lbHash));

    txtView = (TextView) view.findViewById(R.id.CryptoCryptoComponentsPkInfo);
    txtView.setText(TiviPhoneService.getInfo(call.iEngID, call.iCallId, lbKeyExchange));

    txtView = (TextView) view.findViewById(R.id.CryptoCryptoComponentsSauthInfo);
    txtView.setText(TiviPhoneService.getInfo(call.iEngID, call.iCallId, lbAuthTag));

    txtView = (TextView) view.findViewById(R.id.CryptoCryptoComponentsZhashInfo);
    txtView.setText(TiviPhoneService.getInfo(call.iEngID, call.iCallId, sdp_hash));

    txtView = (TextView) view.findViewById(R.id.CryptoPeerClientIdInfo);
    txtView.setText(TiviPhoneService.getInfo(call.iEngID, call.iCallId, lbClient));

    txtView = (TextView) view.findViewById(R.id.CryptoPeerClientProtoInfo);
    txtView.setText(TiviPhoneService.getInfo(call.iEngID, call.iCallId, lbVersion));

    txtView = (TextView) view.findViewById(R.id.CryptoCryptoComponentsTlsInfo);
    String tls = TiviPhoneService.getInfo(call.iEngID, -1, socket);
    txtView.setText(tls);// w  ww .  j av  a2 s.c o m
    txtView.setSelected(true);

    txtView = (TextView) view.findViewById(R.id.CryptoPeerSecureSinceInfo);
    try {
        long since = Long.valueOf(TiviPhoneService.getInfo(call.iEngID, call.iCallId, secureSince));
        if (since <= 0) {
            txtView.setVisibility(View.GONE);
            view.findViewById(R.id.CryptoPeerSecureSince).setVisibility(View.GONE);
        } else {
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
            sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
            txtView.setText(sdf.format(new Date(since * 1000)));
        }
    } catch (NumberFormatException ignore) {
        txtView.setVisibility(View.GONE);
        view.findViewById(R.id.CryptoPeerSecureSince).setVisibility(View.GONE);
    }

    ImageView imgView = (ImageView) view.findViewById(R.id.CryptoSharedSecretsRs1Info);
    CompatibilityHelper.setBackground(imgView, getSharedSecretStatus(mParent, "rs1"));

    imgView = (ImageView) view.findViewById(R.id.CryptoSharedSecretsRs2Info);
    CompatibilityHelper.setBackground(imgView, getSharedSecretStatus(mParent, "rs2"));

    imgView = (ImageView) view.findViewById(R.id.CryptoSharedSecretsAuxInfo);
    CompatibilityHelper.setBackground(imgView, getSharedSecretStatus(mParent, "aux"));

    imgView = (ImageView) view.findViewById(R.id.CryptoSharedSecretsPbxInfo);
    CompatibilityHelper.setBackground(imgView, getSharedSecretStatus(mParent, "pbx"));

    txtView = (TextView) view.findViewById(R.id.CryptoPeerName);
    txtView.setText(call.zrtpPEER.toString());

    txtView = (TextView) view.findViewById(R.id.CryptoSasText);
    txtView.setText(call.bufSAS.toString());

    // if show verify SAS then SAS was not verified
    imgView = (ImageView) view.findViewById(R.id.CryptoPanelPadlock);
    if (call.iShowVerifySas)
        imgView.setImageResource(R.drawable.main_lock_locked);
    else
        imgView.setImageResource(R.drawable.main_lock_verified);
    imgView.setOnClickListener(this);

    // Add inflated view and action buttons
    builder.setView(view).setPositiveButton(R.string.close_dialog, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            mParent.dialogClosed();
        }
    });
    return builder.create();
}

From source file:com.materialdesign.view.tab.VerticalTabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {

        View tabView = createDefaultTabView(getContext());

        TextView tabText = (TextView) tabView.findViewById(R.id.tv_tabText);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        if (mTabs.size() > i) {
            Tab tab = mTabs.get(i);/*from   w ww  .j  a  v  a 2 s .c om*/
            if (tab.icon != 0) {
                tabIcon.setImageResource(tab.icon);
            } else {
                tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextMediumSize);
                int padding = (int) (mTabViewCustomPadding * getResources().getDisplayMetrics().density);
                tabView.setPadding(0, padding, 0, padding);
            }

            if (tab.tabText != null) {
                tabText.setText(tab.tabText);
            }
        }

        tabText.setTextColor(mTabTextColorStateList);

        if (mTabViewTextCustomSize != 0) {
            tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextCustomSize);
        }

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, 0, 1);
        if (i == 0) {
            tabText.setSelected(true);
            tabIcon.setSelected(true);
        }
        mTabStrip.addView(tabView, lp);
    }

    if (hasMiddleTabView) {
        View tabView = LayoutInflater.from(getContext()).inflate(R.layout.tab_layout, null);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        TextView textView = (TextView) tabView.findViewById(R.id.tv_tabText);

        textView.setVisibility(GONE);

        LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(
                (int) (36 * getResources().getDisplayMetrics().density),
                (int) (36 * getResources().getDisplayMetrics().density));
        tabIcon.setLayoutParams(iconParams);
        tabIcon.setImageResource(mMiddleIconResId);

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT,
                1);

        mTabStrip.addView(tabView, 2, lp);
    }
}

From source file:com.zxly.o2o.view.MPagerSlidingTab.java

public void initTabStyles() {
    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);
        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/*from  w ww  .java2 s  .co m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                if (oldTab != null) {
                    oldTab.setSelected(false);
                    ((TextView) oldTab).setTextColor(tabTextColor);
                }
                oldTab = tab;
                tab.setSelected(true);
            }
        }
    }
}

From source file:com.easemob.easeui.widget.viewpagerindicator.PagerSlidingTabStrip.java

public void initTabStyles() {
    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }/* www.ja  v  a2  s  . co m*/
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
                if (oldTab != null) {
                    oldTab.setSelected(false);
                    ((TextView) oldTab).setTextColor(tabTextColor);
                }
                oldTab = tab;
                tab.setSelected(true);
            }
        }
    }
}

From source file:com.materialdesign.view.tab.TabLayout.java

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

    for (int i = 0; i < adapter.getCount(); i++) {

        View tabView = createDefaultTabView(getContext());

        TextView tabText = (TextView) tabView.findViewById(R.id.tv_tabText);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        if (mTabs.size() > i) {
            Tab tab = mTabs.get(i);//from w  w  w .  j av  a  2s . co m
            if (tab.icon != 0) {
                tabIcon.setImageResource(tab.icon);
            } else {
                tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextMediumSize);
                int padding = (int) (mTabViewCustomPadding * getResources().getDisplayMetrics().density);
                tabView.setPadding(0, padding, 0, padding);
            }

            if (tab.tabText != null) {
                tabText.setText(tab.tabText);
            }
        }

        tabText.setTextColor(mTabTextColorStateList);

        if (mTabViewTextCustomSize != 0) {
            tabText.setTextSize(TypedValue.COMPLEX_UNIT_SP, mTabViewTextCustomSize);
        }

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT,
                1);
        if (i == 0) {
            tabText.setSelected(true);
            tabIcon.setSelected(true);
        }
        mTabStrip.addView(tabView, lp);
    }

    //tab,tab-?
    if (hasMiddleTabView) {
        View tabView = LayoutInflater.from(getContext()).inflate(R.layout.tab_layout, null);

        ImageView tabIcon = (ImageView) tabView.findViewById(R.id.iv_tabIcon);

        TextView textView = (TextView) tabView.findViewById(R.id.tv_tabText);

        textView.setVisibility(GONE);

        LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(
                (int) (36 * getResources().getDisplayMetrics().density),
                (int) (36 * getResources().getDisplayMetrics().density));
        tabIcon.setLayoutParams(iconParams);
        tabIcon.setImageResource(mMiddleIconResId);

        tabView.setOnClickListener(tabClickListener);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT,
                1);

        mTabStrip.addView(tabView, 2, lp);
    }
}

From source file:net.fengg.lib.tabsliding.TabSlidingView.java

private void updateTabStyles() {

    for (int i = 0; i < tabCount; i++) {

        View v = tabsContainer.getChildAt(i);

        v.setBackgroundResource(tabBackgroundResId);

        if (v instanceof TextView) {

            TextView tab = (TextView) v;
            tab.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            tab.setTypeface(tabTypeface, tabTypefaceStyle);
            tab.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    tab.setAllCaps(true);
                } else {
                    tab.setText(tab.getText().toString().toUpperCase(locale));
                }//from ww  w . j  a  v  a 2  s .com
            }
            if (i == selectedPosition) {
                tab.setTextColor(selectedTabTextColor);
            }
        } else if (v instanceof ImageButton) {
            ImageButton tab = (ImageButton) v;

            if (i == selectedPosition) {
                //?
                tab.setSelected(true);
            }
        } else {
            LinearLayout l = (LinearLayout) v;

            ImageButton icon = (ImageButton) l.getChildAt(0);
            icon.setBackgroundResource(tabBackgroundResId);
            icon.setSelected(false);
            if (i == selectedPosition) {
                icon.setSelected(true);
            }

            TextView text = (TextView) l.getChildAt(1);
            text.setTextSize(TypedValue.COMPLEX_UNIT_PX, tabTextSize);
            text.setTypeface(tabTypeface, tabTypefaceStyle);
            text.setTextColor(tabTextColor);

            // setAllCaps() is only available from API 14, so the upper case is made manually if we are on a
            // pre-ICS-build
            if (textAllCaps) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
                    text.setAllCaps(true);
                } else {
                    text.setText(text.getText().toString().toUpperCase(locale));
                }
            }
            if (i == selectedPosition) {
                text.setTextColor(selectedTabTextColor);
            }

        }
    }

}

From source file:com.flipzu.flipzu.Player.java

@Override
public void onResponseReceived(BroadcastDataSet bcast) {

    /* unset loading progress */
    setProgressBarIndeterminateVisibility(Boolean.FALSE);

    if (bcast != null) {
        debug.logV(TAG, "onResponseReceived called with bcast " + bcast.getId());
    } else {/*w  w  w  .j  a va  2s  . c om*/
        debug.logV(TAG, "onResponseReceived called with bcast NULL");
    }

    boolean newBcast = false;
    if (bcast != null) {
        /* start async call to fetch user data */
        AsyncFlipInterface.getUser(bcast.getUsername(), user.getToken(), this);

        if (isNewBcast(bcast)) {
            debug.logV(TAG, "onResponseReceived, is a new broadcast");
            saveBcast(bcast);
            newBcast = true;
        } else {
            debug.logV(TAG, "onResponseReceived, is not a new broadcast");
        }
    } else {
        // try again with bcast from settings...
        if (!mSavedBcast) {
            mSavedBcast = true;
            AsyncFlipInterface.getBroadcast(getBcastFromSettings(), this);
        }
        return;
    }

    this.bcast = bcast;

    mUrl = getCurrentUrl(bcast);
    if (bcast != null) {
        mTitle = bcast.getUsername();
        if (bcast.getText() != null)
            mTitle += " - " + bcast.getText();
    }

    debug.logV(TAG, "onResponseReceived, got URL " + mUrl);

    /* layout */
    ImageView bg = (ImageView) findViewById(R.id.user_avatar);

    final TextView title_tv = (TextView) findViewById(R.id.title);
    final TextView time_tv = (TextView) findViewById(R.id.time_str);
    final TextView listeners_tv = (TextView) findViewById(R.id.listeners);
    final TextView username_tv = (TextView) findViewById(R.id.username);
    username_tv.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Player.this, Profile.class);
            i.putExtra("user", ((TextView) findViewById(R.id.username)).getText());
            startActivity(i);
        }
    });

    bg.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent i = new Intent(Player.this, Profile.class);
            i.putExtra("user", ((TextView) findViewById(R.id.username)).getText());
            startActivity(i);
        }
    });

    final TextView bottom_title_tv = (TextView) findViewById(R.id.player_title_bottom);

    // fix padding for player
    //      ScrollingTextView sc_tv = (ScrollingTextView) findViewById(R.id.actionbar_title);
    //      sc_tv.setPadding(35, 0, 0, 0);

    /* action bar */
    //      ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
    //      actionBar.setHomeLogo(R.drawable.logo2);

    if (bcast != null) {
        UrlImageViewHelper.setUrlDrawable(bg, bcast.getImgUrl(), R.drawable.icon_sq);
        getSupportActionBar().setTitle(bcast.getUsername());
        username_tv.setText(bcast.getUsername());
        CharSequence title = bcast.getText();
        if (title == null)
            title = getText(R.string.empty_title);
        title_tv.setText(title);
        bottom_title_tv.setText(mTitle);
        bottom_title_tv.setSelected(true); // hack to make text scroll
        if (bcast.getTimeStr() != null) {
            time_tv.setText(bcast.getTimeStr());
        }
        if (bcast.getListens() == null) {
            // maybe erased? Go back...
            Player.this.finish();
        }
        try {
            Integer listens = Integer.parseInt(bcast.getListens()) + 1;
            listeners_tv.setText(listens.toString());
        } catch (NumberFormatException e) {
            Player.this.finish();
        }
    }

    // EditText comment listener
    final EditText comment_et = (EditText) findViewById(R.id.post_comment_et);
    comment_et.setOnKeyListener(new OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Perform action on key press
                postComment();
                return true;
            }
            return false;
        }
    });

    /* start bcast if it's a new one */
    if (newBcast) {
        debug.logV(TAG, "onResponseReceived, newBcast, sending PLAY");
        sendPlay();
    } else {
        if (mState == playerState.STOPPED)
            sendPlay();
    }

    /* stats thread */
    if (bcast != null) {
        if (bcast.getId() != null) {
            AsyncFlipInterface.getComments(Integer.parseInt(bcast.getId()), Player.this);
        }
        if (bcast.isLive()) {
            if (mState == playerState.PLAYING)
                setLiveVisible(true);
            liveHandler.removeCallbacks(mCheckLiveTask);
            liveHandler.postDelayed(mCheckLiveTask, 5000);
        } else {
            timerHandler.removeCallbacks(mTimerTask);
            timerHandler.postDelayed(mTimerTask, 1000);
        }
    }
}

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

/**
 * @author bbk wangchunhe/*  w w w. j  a  v a 2s . 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();

        }
    });

}