List of usage examples for android.widget TextView setSelected
@Override public void setSelected(boolean selected)
From source file:ch.dissem.apps.abit.SubscriptionDetailFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_subscription_detail, container, false); // Show the dummy content as text in a TextView. if (item != null) { ((ImageView) rootView.findViewById(R.id.avatar)).setImageDrawable(new Identicon(item)); TextView name = (TextView) rootView.findViewById(R.id.name); name.setText(item.toString());/*from w w w . j a v a 2 s . c o m*/ name.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { // Nothing to do } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { // Nothing to do } @Override public void afterTextChanged(Editable s) { item.setAlias(s.toString()); } }); TextView address = (TextView) rootView.findViewById(R.id.address); address.setText(item.getAddress()); address.setSelected(true); ((TextView) rootView.findViewById(R.id.stream_number)) .setText(getActivity().getString(R.string.stream_number, item.getStream())); Switch active = (Switch) rootView.findViewById(R.id.active); active.setChecked(item.isSubscribed()); active.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { item.setSubscribed(isChecked); } }); } return rootView; }
From source file:com.audiokernel.euphonyrmt.fragments.NowPlayingFragment.java
/** * A convenience method to find a resource and set it as selected. * * @param view The view to find the resource in. * @param resource The resource to find in the view. * @return The TextView found in the {@code view}, set as selected. *///from w w w .jav a2 s . c om private static TextView findSelected(final View view, @IdRes final int resource) { final TextView textView = (TextView) view.findViewById(resource); textView.setSelected(true); return textView; }
From source file:com.creationgroundmedia.popularmovies.reviews.ReviewFragment.java
@Override public void onLoadFinished(Loader<List<ReviewItem>> loader, final List<ReviewItem> data) { if (data != null) { for (ReviewItem review : data) { View tv = LayoutInflater.from(getContext()).inflate(R.layout.fragment_review, null); ((LinearLayout) mView).addView(tv); TextView authorView = (TextView) tv.findViewById(R.id.author); authorView.setText(String.format("Review by %s", review.getAuthor())); final TextView contentView = (TextView) tv.findViewById(R.id.content); contentView.setMaxLines(PREVIEW_LINES); contentView.setEllipsize(TextUtils.TruncateAt.END); contentView.setSelected(false); contentView.setText(review.getContent()); tv.setOnClickListener(new View.OnClickListener() { @Override/*from ww w . ja v a2 s . c o m*/ public void onClick(View v) { if (contentView.isSelected()) { contentView.setEllipsize(TextUtils.TruncateAt.END); contentView.setMaxLines(PREVIEW_LINES); contentView.setSelected(false); } else { contentView.setEllipsize(null); contentView.setMaxLines(Integer.MAX_VALUE); contentView.setSelected(true); } } }); } getLoaderManager().destroyLoader(URL_REVIEWLOADER); } }
From source file:com.sim2dial.dialer.ContactFragment.java
private void displayContact(LayoutInflater inflater, View view) { AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream( LinphoneActivity.instance().getContentResolver(), contact.getID()); contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); } else {/*from ww w.j a va 2 s. c o m*/ contactPicture.setImageResource(R.drawable.unknown_small); } TextView contactName = (TextView) view.findViewById(R.id.contactName); contactName.setText(contact.getName()); TableLayout controls = (TableLayout) view.findViewById(R.id.controls); controls.removeAllViews(); for (String numberOrAddress : contact.getNumerosOrAddresses()) { View v = inflater.inflate(R.layout.contact_control_row, null); String displayednumberOrAddress = numberOrAddress; if (numberOrAddress.startsWith("sip:")) { displayednumberOrAddress = displayednumberOrAddress.substring(4); } TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); tv.setText(displayednumberOrAddress); tv.setSelected(true); if (!displayChatAddressOnly) { v.findViewById(R.id.dial).setOnClickListener(dialListener); v.findViewById(R.id.dial).setTag(displayednumberOrAddress); } else { v.findViewById(R.id.dial).setVisibility(View.GONE); } v.findViewById(R.id.chat).setOnClickListener(chatListener); if (LinphoneUtils.isSipAddress(numberOrAddress)) { v.findViewById(R.id.chat).setTag(numberOrAddress); } else { LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (lpc != null) { if (!numberOrAddress.startsWith("sip:")) { numberOrAddress = "sip:" + numberOrAddress; } v.findViewById(R.id.chat).setTag(numberOrAddress + "@" + lpc.getDomain()); } } final String finalNumberOrAddress = numberOrAddress; ImageView friend = (ImageView) v.findViewById(R.id.addFriend); if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) { friend.setVisibility(View.VISIBLE); boolean isAlreadyAFriend = LinphoneManager.getLc() .findFriendByAddress(finalNumberOrAddress) != null; if (!isAlreadyAFriend) { friend.setImageResource(R.drawable.friend_add); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } else { friend.setImageResource(R.drawable.friend_remove); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } } if (getResources().getBoolean(R.bool.disable_chat)) { v.findViewById(R.id.chat).setVisibility(View.GONE); } controls.addView(v); } }
From source file:viewpager.TabPageIndicator.java
@Override public void setCurrentItem(int item) { if (mViewPager == null) { throw new IllegalStateException("ViewPager has not been bound."); }/*from w w w.jav a 2 s. c om*/ mSelectedTabIndex = item; mViewPager.setCurrentItem(item); final int tabCount = mTabLayout.getChildCount(); for (int i = 0; i < tabCount; i++) { final TextView child = (TextView) mTabLayout.getChildAt(i); final boolean isSelected = (i == item); child.setSelected(isSelected); if (isSelected) { animateToTab(item); child.setTextColor(mSelectedColor); } else child.setTextColor(mUnselectedColor); } }
From source file:org.linphone.ContactFragment.java
@SuppressLint("InflateParams") private void displayContact(LayoutInflater inflater, View view) { AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream( LinphoneActivity.instance().getContentResolver(), contact.getID()); contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); } else {/*from ww w. ja v a 2 s. c o m*/ contactPicture.setImageResource(R.drawable.unknown_small); } TextView contactName = (TextView) view.findViewById(R.id.contactName); contactName.setText(contact.getName()); TableLayout controls = (TableLayout) view.findViewById(R.id.controls); controls.removeAllViews(); for (String numberOrAddress : contact.getNumbersOrAddresses()) { View v = inflater.inflate(R.layout.contact_control_row, null); String displayednumberOrAddress = numberOrAddress; if (numberOrAddress.startsWith("sip:")) { displayednumberOrAddress = displayednumberOrAddress.replace("sip:", ""); } TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); tv.setText(displayednumberOrAddress); tv.setSelected(true); if (!displayChatAddressOnly) { v.findViewById(R.id.dial).setOnClickListener(dialListener); v.findViewById(R.id.dial).setTag(displayednumberOrAddress); } else { v.findViewById(R.id.dial).setVisibility(View.GONE); } v.findViewById(R.id.start_chat).setOnClickListener(chatListener); LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (lpc != null) { displayednumberOrAddress = lpc.normalizePhoneNumber(displayednumberOrAddress); if (!displayednumberOrAddress.startsWith("sip:")) { numberOrAddress = "sip:" + displayednumberOrAddress; } String tag = numberOrAddress; if (!numberOrAddress.contains("@")) { tag = numberOrAddress + "@" + lpc.getDomain(); } v.findViewById(R.id.start_chat).setTag(tag); } else { v.findViewById(R.id.start_chat).setTag(numberOrAddress); } final String finalNumberOrAddress = numberOrAddress; ImageView friend = (ImageView) v.findViewById(R.id.addFriend); if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) { friend.setVisibility(View.VISIBLE); boolean isAlreadyAFriend = LinphoneManager.getLc() .findFriendByAddress(finalNumberOrAddress) != null; if (!isAlreadyAFriend) { friend.setImageResource(R.drawable.friend_add); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (ContactsManager.getInstance().createNewFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } else { friend.setImageResource(R.drawable.friend_remove); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (ContactsManager.getInstance().removeFriend(finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } } if (getResources().getBoolean(R.bool.disable_chat)) { v.findViewById(R.id.start_chat).setVisibility(View.GONE); } controls.addView(v); } }
From source file:org.xingjitong.ContactFragment.java
private void displayContact(LayoutInflater inflater, View view) { AvatarWithShadow contactPicture = (AvatarWithShadow) view.findViewById(R.id.contactPicture); if (contact.getPhotoUri() != null) { InputStream input = Compatibility.getContactPictureInputStream(getActivity().getContentResolver(), contact.getID());//from w w w .j ava 2 s. co m contactPicture.setImageBitmap(BitmapFactory.decodeStream(input)); } else { contactPicture.setImageResource(R.drawable.unknown_small); } TextView contactName = (TextView) view.findViewById(R.id.contactName); contactName.setText(contact.getName()); contactName.setTextColor(Color.BLACK); View view2 = inflater.inflate(R.layout.edit_contact, null); TableLayout controls = (TableLayout) view2.findViewById(R.id.controls); if (controls.getChildCount() > 0 && controls != null) { controls.removeAllViews(); } for (String numberOrAddress : contact.getNumerosOrAddresses()) { //yyppdialog View v = inflater.inflate(R.layout.contact_control_row, null); String displayednumberOrAddress = numberOrAddress; if (numberOrAddress.startsWith("sip:")) { displayednumberOrAddress = displayednumberOrAddress.substring(4); } TextView tv = (TextView) v.findViewById(R.id.numeroOrAddress); tv.setText(displayednumberOrAddress); tv.setSelected(true); if (!displayChatAddressOnly) { //yyppcontact //yyppdialog v.findViewById(R.id.dial).setOnClickListener(dialListener); v.findViewById(R.id.dial).setTag(displayednumberOrAddress); } else { v.findViewById(R.id.dial).setVisibility(View.GONE); } v.findViewById(R.id.chat).setOnClickListener(chatListener); if (LinphoneUtils.isSipAddress(numberOrAddress)) { v.findViewById(R.id.chat).setTag(numberOrAddress); } else { LinphoneProxyConfig lpc = LinphoneManager.getLc().getDefaultProxyConfig(); if (lpc != null) { if (!numberOrAddress.startsWith("sip:")) { numberOrAddress = "sip:" + numberOrAddress; } v.findViewById(R.id.chat).setTag(numberOrAddress + "@" + lpc.getDomain()); } } final String finalNumberOrAddress = numberOrAddress; ImageView friend = (ImageView) v.findViewById(R.id.addFriend); if (getResources().getBoolean(R.bool.enable_linphone_friends) && !displayChatAddressOnly) { friend.setVisibility(View.VISIBLE); boolean isAlreadyAFriend = LinphoneManager.getLc() .findFriendByAddress(finalNumberOrAddress) != null; if (!isAlreadyAFriend) { friend.setImageResource(R.drawable.friend_add); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().newFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } else { friend.setImageResource(R.drawable.friend_remove); friend.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (LinphoneActivity.instance().removeFriend(contact, finalNumberOrAddress)) { displayContact(ContactFragment.this.inflater, ContactFragment.this.view); } } }); } } if (getResources().getBoolean(R.bool.disable_chat)) { v.findViewById(R.id.chat).setVisibility(View.GONE); } controls.addView(v); } }
From source file:com.example.rogerzzzz.cityrecall.widget.SlidingTabLayout.java
public void setTabSelected(int position) { for (int i = 0; i < mTabStrip.getChildCount(); i++) { TextView textView = (TextView) mTabStrip.getChildAt(i); textView.setTextColor(position == i ? textColorSelected : textColor); textView.setSelected(position == i); }/*w ww.j a va 2 s . c o m*/ }
From source file:com.android.settings.widget.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); for (int i = 0; i < adapter.getCount(); i++) { final TextView tabTitleView = (TextView) mLayoutInflater.inflate(R.layout.sliding_tab_title_view, mTitleView, false);/*from w ww. ja v a 2s. c o m*/ tabTitleView.setText(adapter.getPageTitle(i)); tabTitleView.setOnClickListener(this); mTitleView.addView(tabTitleView); tabTitleView.setSelected(i == mViewPager.getCurrentItem()); } }
From source file:com.rukiasoft.androidapps.cocinaconroll.ui.ToolbarAndRefreshActivity.java
public void setToolbar(Toolbar toolbar) { setSupportActionBar(toolbar);/*from w w w . j a va 2 s . c o m*/ getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(true); try { if (toolbar.getClass() != null) { Field f = toolbar.getClass().getDeclaredField("mTitleTextView"); f.setAccessible(true); TextView titleTextView = (TextView) f.get(toolbar); titleTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE); titleTextView.setFocusable(true); titleTextView.setFocusableInTouchMode(true); titleTextView.requestFocus(); titleTextView.setSingleLine(true); titleTextView.setSelected(true); titleTextView.setMarqueeRepeatLimit(-1); } } catch (NoSuchFieldException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } }