List of usage examples for android.widget TextView setSelected
@Override public void setSelected(boolean selected)
From source file:cn.org.eshow.framwork.view.sliding.AbSlidingSmoothTabView.java
/** * ???.//w w w .jav a2 s .com * * @param index the index */ public void computeTabImg(int index) { for (int i = 0; i < tabItemList.size(); i++) { TextView tv = tabItemList.get(i); tv.setTextColor(tabColor); tv.setSelected(false); if (index == i) { tv.setTextColor(tabSelectColor); tv.setSelected(true); } } // final View tabView = mTabLayout.getChildAt(index); AbViewUtil.measureView(tabView); LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight); mParams.topMargin = -tabSlidingHeight; mTabImg.setLayoutParams(mParams); AbLogUtil.d(AbSlidingSmoothTabView.class, "old--startX:" + startX); //????????tab AbLogUtil.d(AbSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth()); AbLogUtil.d(AbSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth()); AbLogUtil.d(AbSlidingSmoothTabView.class, "scrollX:" + scrollX); AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView right:" + tabView.getRight()); AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft()); if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) { AbLogUtil.d(AbSlidingSmoothTabView.class, "??"); int offsetX = 0; //?? if (index == mTabLayout.getChildCount() - 1) { offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0); startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth(); } else { offsetX = tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) { AbLogUtil.d(AbSlidingSmoothTabView.class, "?"); //? offsetX int offsetX = 0; if (index == 0) { offsetX = -scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; imageSlide(mTabImg, startX, 0, 0, 0); startX = 0; } else { offsetX = -tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else { int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } mSelectedTabIndex = index; }
From source file:com.bangqu.eshow.view.sliding.ESSlidingSmoothTabView.java
/** * ???.// w w w . j a va2 s. c om * * @param index the index */ public void computeTabImg(int index) { for (int i = 0; i < tabItemList.size(); i++) { TextView tv = tabItemList.get(i); tv.setTextColor(tabColor); tv.setSelected(false); if (index == i) { tv.setTextColor(tabSelectColor); tv.setSelected(true); } } // final View tabView = mTabLayout.getChildAt(index); ESViewUtil.measureView(tabView); LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight); mParams.topMargin = -tabSlidingHeight; mTabImg.setLayoutParams(mParams); ESLogUtil.d(ESSlidingSmoothTabView.class, "old--startX:" + startX); //????????tab ESLogUtil.d(ESSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth()); ESLogUtil.d(ESSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth()); ESLogUtil.d(ESSlidingSmoothTabView.class, "scrollX:" + scrollX); ESLogUtil.d(ESSlidingSmoothTabView.class, "tabView right:" + tabView.getRight()); ESLogUtil.d(ESSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft()); if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) { ESLogUtil.d(ESSlidingSmoothTabView.class, "??"); int offsetX = 0; //?? if (index == mTabLayout.getChildCount() - 1) { offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; ESLogUtil.d(ESSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0); startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth(); } else { offsetX = tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; ESLogUtil.d(ESSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) { ESLogUtil.d(ESSlidingSmoothTabView.class, "?"); //? offsetX int offsetX = 0; if (index == 0) { offsetX = -scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; imageSlide(mTabImg, startX, 0, 0, 0); startX = 0; } else { offsetX = -tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; ESLogUtil.d(ESSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else { int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } mSelectedTabIndex = index; }
From source file:com.itheima.googlemarket.PagerSlidingTabStrip.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); if (position == 0) { tab.setSelected(true); // ?1tab }/*from w w w. ja v a 2 s.c o m*/ tab.setText(title); tab.setGravity(Gravity.CENTER); tab.setSingleLine(); addTab(position, tab); }
From source file:com.appybite.customer.RegisterActivity.java
private void updateHotelList() { //. Department List llHotelList.removeAllViews();//from w w w .ja va 2 s. c o m for (int i = 0; i < aryHotelList.size(); i++) { final HotelInfo value = aryHotelList.get(i); LayoutInflater vi = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); View item = null; if (DeviceUtil.isTabletByRes(this)) item = vi.inflate(R.layout.item_depart_tab, llHotelList, false); else item = vi.inflate(R.layout.item_depart, llHotelList, false); ImageView ivThumb = (ImageView) item.findViewById(R.id.ivThumb); if (value.license == "pro") { ImageLoader.getInstance().displayImage(value.hotel_logo, ivThumb, options, animateFirstListener); } else if (value.license == "demo") { ImageLoader.getInstance().displayImage(value.hotel_logo, ivThumb, options, animateFirstListener); } TextView tvTitle = (TextView) item.findViewById(R.id.tvTitle); tvTitle.setText(value.hotel_name); tvTitle.setSelected(true); if (i == 0) tvTitle.setTextColor(getResources().getColor(R.color.Goldenrod)); item.setTag(tvTitle); item.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { unselectHotels(); ((TextView) arg0.getTag()).setTextColor(getResources().getColor(R.color.Goldenrod)); hotel_id = value.hotel_id; hotel_license = value.license; } }); if (!PRJFUNC.DEFAULT_SCREEN) { PRJFUNC.mGrp.relayoutView(item, LayoutLib.LP_LinearLayout); PRJFUNC.mGrp.setTextViewFontScale(tvTitle); PRJFUNC.mGrp.repaddingView(tvTitle); PRJFUNC.mGrp.relayoutView(item.findViewById(R.id.ivShadowTop), LayoutLib.LP_RelativeLayout); PRJFUNC.mGrp.relayoutView(item.findViewById(R.id.ivShadowBottom), LayoutLib.LP_RelativeLayout); } llHotelList.addView(item); } }
From source file:com.tony.selene.sliding.AbSlidingSmoothTabView.java
/** * ???.//from w w w . j a v a2s . c o m * * @param index * the index */ public void computeTabImg(int index) { for (int i = 0; i < tabItemList.size(); i++) { TextView tv = tabItemList.get(i); tv.setTextColor(tabColor); tv.setSelected(false); if (index == i) { tv.setTextColor(tabSelectColor); tv.setSelected(true); } } // final View tabView = mTabLayout.getChildAt(index); AbViewUtil.measureView(tabView); LayoutParams mParams = new LayoutParams(tabView.getMeasuredWidth(), tabSlidingHeight); mParams.topMargin = -tabSlidingHeight; mTabImg.setLayoutParams(mParams); AbLogUtil.d(AbSlidingSmoothTabView.class, "old--startX:" + startX); // ????????tab AbLogUtil.d(AbSlidingSmoothTabView.class, "view" + index + ":" + tabView.getMeasuredWidth()); AbLogUtil.d(AbSlidingSmoothTabView.class, "ScrollView:" + mTabScrollView.getWidth()); AbLogUtil.d(AbSlidingSmoothTabView.class, "scrollX:" + scrollX); AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView right:" + tabView.getRight()); AbLogUtil.d(AbSlidingSmoothTabView.class, "tabView left:" + tabView.getLeft()); if (mSelectedTabIndex < index && tabView.getRight() - scrollX > mTabScrollView.getWidth()) { AbLogUtil.d(AbSlidingSmoothTabView.class, "??"); int offsetX = 0; // ?? if (index == mTabLayout.getChildCount() - 1) { offsetX = tabView.getRight() - mTabScrollView.getWidth() - scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); imageSlide(mTabImg, startX, mTabScrollView.getWidth() - tabView.getMeasuredWidth(), 0, 0); startX = mTabScrollView.getWidth() - tabView.getMeasuredWidth(); } else { offsetX = tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else if (mSelectedTabIndex > index && tabView.getLeft() < scrollX) { AbLogUtil.d(AbSlidingSmoothTabView.class, "?"); // ? offsetX int offsetX = 0; if (index == 0) { offsetX = -scrollX; mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; imageSlide(mTabImg, startX, 0, 0, 0); startX = 0; } else { offsetX = -tabView.getMeasuredWidth(); mTabScrollView.smoothScrollBy(offsetX, 0); scrollX = scrollX + offsetX; AbLogUtil.d(AbSlidingSmoothTabView.class, "startX2:" + startX + ",offsetX:" + offsetX); int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } } else { int toX = tabView.getLeft() - scrollX; imageSlide(mTabImg, startX, toX, 0, 0); startX = toX; } mSelectedTabIndex = index; }
From source file:com.ekuater.labelchat.ui.widget.PagerSlidingTabStrip.java
private void setTabSelected(int position) { for (int i = 0; i < tabCount; i++) { final TextView tab = (TextView) tabsContainer.getChildAt(i); final boolean isSelected = i == position; tab.setSelected(isSelected); tab.setTypeface(tabTypeface, isSelected ? tabSelectedTypefaceStyle : tabTypefaceStyle); }/*from w ww .j av a2 s .c o m*/ }
From source file:cn.hollo.www.custom_view.PagerSlidingTabStrip.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.setSelected(currentPosition == i); // 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 . ja v a 2s . com } } } }
From source file:org.mozilla.gecko.overlays.ui.ShareDialog.java
@Override protected void onResume() { super.onResume(); final Intent intent = getIntent(); state = intent.getBooleanExtra(INTENT_EXTRA_DEVICES_ONLY, false) ? State.DEVICES_ONLY : State.DEFAULT; // If the Activity is being reused, we need to reset the state. Ideally, we create a // new instance for each call, but Android L breaks this (bug 1137928). sendTabList.switchState(SendTabList.State.LOADING); readingListButton.setBackgroundDrawable(readingListButtonDrawable); // The URL is usually hiding somewhere in the extra text. Extract it. final String extraText = ContextUtils.getStringExtra(intent, Intent.EXTRA_TEXT); if (TextUtils.isEmpty(extraText)) { abortDueToNoURL();//from www . ja va2s.c o m return; } final String pageUrl = new WebURLFinder(extraText).bestWebURL(); if (TextUtils.isEmpty(pageUrl)) { abortDueToNoURL(); return; } // Have the service start any initialisation work that's necessary for us to show the correct // UI. The results of such work will come in via the BroadcastListener. Intent serviceStartupIntent = new Intent(this, OverlayActionService.class); serviceStartupIntent.setAction(OverlayConstants.ACTION_PREPARE_SHARE); startService(serviceStartupIntent); // Start the slide-up animation. getWindow().setWindowAnimations(0); final Animation anim = AnimationUtils.loadAnimation(this, R.anim.overlay_slide_up); findViewById(R.id.sharedialog).startAnimation(anim); // If provided, we use the subject text to give us something nice to display. // If not, we wing it with the URL. // TODO: Consider polling Fennec databases to find better information to display. final String subjectText = intent.getStringExtra(Intent.EXTRA_SUBJECT); final String telemetryExtras = "title=" + (subjectText != null); if (subjectText != null) { ((TextView) findViewById(R.id.title)).setText(subjectText); } Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.SHARE_OVERLAY, telemetryExtras); title = subjectText; url = pageUrl; // Set the subtitle text on the view and cause it to marquee if it's too long (which it will // be, since it's a URL). final TextView subtitleView = (TextView) findViewById(R.id.subtitle); subtitleView.setText(pageUrl); subtitleView.setEllipsize(TextUtils.TruncateAt.MARQUEE); subtitleView.setSingleLine(true); subtitleView.setMarqueeRepeatLimit(5); subtitleView.setSelected(true); final View titleView = findViewById(R.id.title); if (state == State.DEVICES_ONLY) { bookmarkButton.setVisibility(View.GONE); readingListButton.setVisibility(View.GONE); titleView.setOnClickListener(null); subtitleView.setOnClickListener(null); return; } bookmarkButton.setVisibility(View.VISIBLE); readingListButton.setVisibility(View.VISIBLE); // Configure buttons. final View.OnClickListener launchBrowser = new View.OnClickListener() { @Override public void onClick(View view) { ShareDialog.this.launchBrowser(); } }; titleView.setOnClickListener(launchBrowser); subtitleView.setOnClickListener(launchBrowser); final LocalBrowserDB browserDB = new LocalBrowserDB(getCurrentProfile()); setButtonState(url, browserDB); }
From source file:com.kaszubski.kamil.emmhelper.MainActivity.java
private void longTextTitleMode(boolean enabled) { try {//from w ww.j a va 2 s . c o m Field titleField = Toolbar.class.getDeclaredField("mTitleTextView"); titleField.setAccessible(enabled); TextView barTitleView = (TextView) titleField.get(toolbar); barTitleView.setEllipsize(enabled ? TextUtils.TruncateAt.START : TextUtils.TruncateAt.START); barTitleView.setFocusable(enabled); barTitleView.setFocusableInTouchMode(enabled); barTitleView.requestFocus(); barTitleView.setSingleLine(enabled); barTitleView.setSelected(enabled); } catch (NoSuchFieldException e) { Log.e(TAG, "" + e); } catch (IllegalAccessException e) { Log.e(TAG, " " + e); } }
From source file:com.example.capstone.view.PagerSlidingTabStrip.java
private void updateActivateTab(final int position) { for (int i = 0; i < tabCount; i++) { View v = tabsContainer.getChildAt(i); if (v instanceof TextView) { TextView tab = (TextView) v; tab.setTextColor(position == i ? tabTextColor : tabDeactivateTextColor); } else if (v instanceof ImageButton) { ImageButton tab = (ImageButton) v; tab.setSelected(position == i ? true : false); }/*from w w w . j a v a 2 s.co m*/ } }