List of usage examples for android.text SpannableString SpannableString
public SpannableString(CharSequence source)
From source file:com.pax.pay.trans.action.activity.InputTransData2Activity.java
private void setEditText_date(EditText editText) { SpannableString ss = new SpannableString(getString(R.string.prompt_date_default2)); AbsoluteSizeSpan ass = new AbsoluteSizeSpan(getResources().getDimensionPixelOffset(R.dimen.font_size_large), false);/*from ww w . ja va 2 s. c om*/ ss.setSpan(ass, 0, ss.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); editText.setHint(new SpannedString(ss)); // ??,? editText.setHintTextColor(getResources().getColor(R.color.textEdit_hint)); editText.setInputType(InputType.TYPE_CLASS_NUMBER); editText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(4) }); }
From source file:com.citrus.sdk.fragments.SavedOptions.java
private void showSignInFlow(String errorMessage) { signInLayout = (RelativeLayout) returnView.findViewById(R.id.signInLayout); signInLayout.setVisibility(View.VISIBLE); usernameET = (EditText) returnView.findViewById(R.id.username); passwordET = (EditText) returnView.findViewById(R.id.password); errorText = (TextView) returnView.findViewById(R.id.errorText); resetPass = (TextView) returnView.findViewById(R.id.resetPass); passwordET.requestFocus();//from w w w. jav a 2s . c o m String udata = "Reset Password?"; SpannableString content = new SpannableString(udata); content.setSpan(new UnderlineSpan(), 0, udata.length(), 0); resetPass.setText(content); usernameET.setText(OneClicksignup.getDefaultGmail(getActivity())); errorText.setText(errorMessage); Button signIn = (Button) returnView.findViewById(R.id.signIn); signIn.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { String username = usernameET.getText().toString(); String password = passwordET.getText().toString(); String params[] = new String[] { username, password }; signInLayout.setVisibility(View.INVISIBLE); progressBar.setVisibility(View.VISIBLE); new SignInAsynch(getActivity(), signInListener).execute(params); } }); resetPass.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { showPopup(); } }); }
From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //get last pet used SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(this); mSelectedGooglyPet = sp.getInt(SharedPreferencesUtils.PREF_USER_GOOGLY_PET_SELECTED, GooglyPetUtils.GOOGLY_PET_ZEBRA); mNavigationDrawerFragment = (NavigationDrawerFragment) getFragmentManager() .findFragmentById(R.id.navigation_drawer); mTitle = new SpannableString(getTitle()); mActionBarIcon = R.drawable.ic_launcher; mNavigationDrawerFragment.selectEntry(mSelectedGooglyPet); // Set up the drawer. mNavigationDrawerFragment.setUp(R.id.navigation_drawer, (DrawerLayout) findViewById(R.id.drawer_layout)); //set up rounded overlay opened when instruction are requested setUpRoundedOverlay();/* w w w.j av a2 s . c om*/ //set up instruction for sharing screen shot setUpInstructions(); //set up animations setUpAnimations(); //set up capture preview setUpCapturePreview(); //set up saving button setUpSavingButton(); //set up sharing button setUpSharingButton(); mLastTouchTimeStamp = 0; mPreviewRequested = false; mPetTrackerFragment = new PetTrackerFragment(); //set saved pet in shared preferences as arguments final Bundle data = new Bundle(); data.putInt(PetTrackerFragment.BUNDLE_KEY_GOOGLY_PET, mSelectedGooglyPet); mPetTrackerFragment.setArguments(data); //display fragment getSupportFragmentManager().beginTransaction().replace(R.id.container, mPetTrackerFragment).commit(); }
From source file:com.zd.vpn.fragments.AboutFragment.java
private void createPlayBuyOptions(ArrayList<String> ownedSkus, ArrayList<String> responseList) { try {//from ww w. j av a 2 s. c o m Vector<Pair<String, String>> gdonation = new Vector<Pair<String, String>>(); gdonation.add(new Pair<String, String>(getString(R.string.donatePlayStore), null)); HashMap<String, SkuResponse> responseMap = new HashMap<String, SkuResponse>(); for (String thisResponse : responseList) { JSONObject object = new JSONObject(thisResponse); responseMap.put(object.getString("productId"), new SkuResponse(object.getString("price"), object.getString("title"))); } for (String sku : donationSkus) if (responseMap.containsKey(sku)) gdonation.add( getSkuTitle(sku, responseMap.get(sku).title, responseMap.get(sku).price, ownedSkus)); String gmsTextString = ""; for (int i = 0; i < gdonation.size(); i++) { if (i == 1) gmsTextString += " "; else if (i > 1) gmsTextString += ", "; gmsTextString += gdonation.elementAt(i).first; } SpannableString gmsText = new SpannableString(gmsTextString); int lStart = 0; int lEnd = 0; for (Pair<String, String> item : gdonation) { lEnd = lStart + item.first.length(); if (item.second != null) { final String mSku = item.second; ClickableSpan cspan = new ClickableSpan() { @Override public void onClick(View widget) { triggerBuy(mSku); } }; gmsText.setSpan(cspan, lStart, lEnd, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } lStart = lEnd + 2; // Account for ", " between items } if (gmsTextView != null) { gmsTextView.setText(gmsText); gmsTextView.setMovementMethod(LinkMovementMethod.getInstance()); gmsTextView.setVisibility(View.VISIBLE); } } catch (JSONException e) { VpnStatus.logException("Parsing Play Store IAP", e); } }
From source file:com.aniruddhc.acemusic.player.PlaylistEditorActivity.PlaylistEditorActivity.java
@Override public boolean onCreateOptionsMenu(Menu menu) { MenuInflater inflater = getMenuInflater(); inflater.inflate(R.menu.add_to_music_library, menu); ActionBar actionBar = getActionBar(); SpannableString s = new SpannableString(getResources().getString(R.string.create_playlist)); s.setSpan(new TypefaceSpan(this, "RobotoCondensed-Light"), 0, s.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); actionBar.setTitle(s);/*from w w w . j a v a 2s . c o m*/ return super.onCreateOptionsMenu(menu); }
From source file:eu.veldsoft.adsbobball.ActivityStateEnum.java
public SpannableStringBuilder formatPerPlayer(String fixed, playstat query) { SpannableStringBuilder sps = SpannableStringBuilder.valueOf(fixed); for (Player p : gameManager.getCurrGameState().getPlayers()) { if (p.getPlayerId() == 0) continue; SpannableString s = new SpannableString(String.valueOf(query.call(p)) + " "); s.setSpan(new ForegroundColorSpan(p.getColor()), 0, s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); sps.append(s);/* w w w . j a v a2 s . c o m*/ } return sps; }
From source file:task.application.com.colette.navigation.AppNavigationViewAsDrawerImpl.java
private void applyFontToMenuItem(MenuItem mi) { Typeface font = FontCache.getTypeface("Nunito-SemiBold.ttf", mActivity); SpannableString mNewTitle = new SpannableString(mi.getTitle()); mNewTitle.setSpan(new CustomTypefaceSpan("", font), 0, mNewTitle.length(), Spannable.SPAN_INCLUSIVE_INCLUSIVE); mi.setTitle(mNewTitle);/* w w w .jav a2 s . c o m*/ }
From source file:org.tlhInganHol.android.klingonassistant.BaseActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { mActivePosition = savedInstanceState.getInt(STATE_ACTIVE_POSITION); }/* w w w .j a v a 2 s . c o m*/ // Close the floating window, if there is one. Work around a race condition. Log.d(TAG, "Starting activity with non-floating window. Close floating window."); Handler killFloatingWindowHandler = new Handler(); Runnable killFloatingWindowRunnable = new Runnable() { public void run() { StandOutWindow.closeAll(BaseActivity.this, FloatingWindow.class); } }; killFloatingWindowHandler.postDelayed(killFloatingWindowRunnable, 100); // 100 ms // Get the action bar. ActionBar actionBar = getSupportActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); if (sharedPrefs.getBoolean(Preferences.KEY_KLINGON_FONT_CHECKBOX_PREFERENCE, /* default */false)) { // Display the action bar title in Klingon font. SpannableString title = new SpannableString("?"); Typeface klingonTypeface = KlingonAssistant.getKlingonFontTypeface(getBaseContext()); title.setSpan(new KlingonTypefaceSpan("", klingonTypeface), 0, title.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); actionBar.setTitle(title); } // If the device is in landscape orientation and the screen size is large (or bigger), then // make the slide-out menu static. Otherwise, hide it by default. MenuDrawer.Type drawerType = MenuDrawer.Type.BEHIND; if (isHorizontalTablet()) { drawerType = MenuDrawer.Type.STATIC; } mDrawer = MenuDrawer.attach(this, drawerType, Position.LEFT, MenuDrawer.MENU_DRAG_CONTENT); List<Object> items = new ArrayList<Object>(); if (sharedPrefs.getBoolean(Preferences.KEY_KLINGON_UI_CHECKBOX_PREFERENCE, /* default */false)) { items.add(new SlideMenuCategory(R.string.menu_reference_tlh)); items.add(new SlideMenuItem(R.string.menu_pronunciation_tlh, R.id.pronunciation, 0)); items.add(new SlideMenuItem(R.string.menu_prefixes_tlh, R.id.prefixes, 0)); items.add(new SlideMenuItem(R.string.menu_prefix_charts_tlh, R.id.prefix_charts, 0)); items.add(new SlideMenuItem(R.string.menu_noun_suffixes_tlh, R.id.noun_suffixes, 0)); items.add(new SlideMenuItem(R.string.menu_verb_suffixes_tlh, R.id.verb_suffixes, 0)); items.add(new SlideMenuCategory(R.string.menu_phrases_tlh)); items.add(new SlideMenuItem(R.string.beginners_conversation_tlh, R.id.beginners_conversation, 0)); items.add(new SlideMenuItem(R.string.jokes_tlh, R.id.jokes, 0)); items.add(new SlideMenuItem(R.string.nentay_tlh, R.id.nentay, 0)); items.add(new SlideMenuItem(R.string.military_celebration_tlh, R.id.military_celebration, 0)); items.add(new SlideMenuItem(R.string.toasts_tlh, R.id.toasts, 0)); items.add(new SlideMenuItem(R.string.lyrics_tlh, R.id.lyrics, 0)); items.add(new SlideMenuItem(R.string.curse_warfare_tlh, R.id.curse_warfare, 0)); items.add(new SlideMenuItem(R.string.replacement_proverbs_tlh, R.id.replacement_proverbs, 0)); items.add(new SlideMenuItem(R.string.secrecy_proverbs_tlh, R.id.secrecy_proverbs, 0)); items.add(new SlideMenuItem(R.string.empire_union_day_tlh, R.id.empire_union_day, 0)); items.add(new SlideMenuItem(R.string.rejection_tlh, R.id.rejection, 0)); items.add(new SlideMenuCategory(R.string.menu_media_tlh)); items.add(new SlideMenuItem(R.string.media_1_title_tlh, R.id.media_1, 0)); items.add(new SlideMenuItem(R.string.media_2_title_tlh, R.id.media_2, 0)); items.add(new SlideMenuItem(R.string.media_3_title_tlh, R.id.media_3, 0)); items.add(new SlideMenuItem(R.string.media_4_title_tlh, R.id.media_4, 0)); items.add(new SlideMenuItem(R.string.media_5_title_tlh, R.id.media_5, 0)); items.add(new SlideMenuItem(R.string.media_6_title_tlh, R.id.media_6, 0)); /* items.add(new SlideMenuCategory(R.string.menu_social_tlh)); items.add(new SlideMenuItem(R.string.menu_gplus_tlh, R.id.gplus, 0)); items.add(new SlideMenuItem(R.string.menu_facebook_tlh, R.id.facebook, 0)); items.add(new SlideMenuItem(R.string.menu_kag_tlh, R.id.kag, 0)); items.add(new SlideMenuItem(R.string.menu_kidc_tlh, R.id.kidc, 0)); */ } else { items.add(new SlideMenuCategory(R.string.menu_reference)); items.add(new SlideMenuItem(R.string.menu_pronunciation, R.id.pronunciation, 0)); items.add(new SlideMenuItem(R.string.menu_prefixes, R.id.prefixes, 0)); items.add(new SlideMenuItem(R.string.menu_prefix_charts, R.id.prefix_charts, 0)); items.add(new SlideMenuItem(R.string.menu_noun_suffixes, R.id.noun_suffixes, 0)); items.add(new SlideMenuItem(R.string.menu_verb_suffixes, R.id.verb_suffixes, 0)); items.add(new SlideMenuCategory(R.string.menu_phrases)); items.add(new SlideMenuItem(R.string.beginners_conversation, R.id.beginners_conversation, 0)); items.add(new SlideMenuItem(R.string.jokes, R.id.jokes, 0)); items.add(new SlideMenuItem(R.string.nentay, R.id.nentay, 0)); items.add(new SlideMenuItem(R.string.military_celebration, R.id.military_celebration, 0)); items.add(new SlideMenuItem(R.string.toasts, R.id.toasts, 0)); items.add(new SlideMenuItem(R.string.lyrics, R.id.lyrics, 0)); items.add(new SlideMenuItem(R.string.curse_warfare, R.id.curse_warfare, 0)); items.add(new SlideMenuItem(R.string.replacement_proverbs, R.id.replacement_proverbs, 0)); items.add(new SlideMenuItem(R.string.secrecy_proverbs, R.id.secrecy_proverbs, 0)); items.add(new SlideMenuItem(R.string.empire_union_day, R.id.empire_union_day, 0)); items.add(new SlideMenuItem(R.string.rejection, R.id.rejection, 0)); // Not all general proverbs are properly tagged yet. // Too many idioms; also no known Klingon term for "idiom". items.add(new SlideMenuCategory(R.string.menu_media)); items.add(new SlideMenuItem(R.string.media_1_title, R.id.media_1, 0)); items.add(new SlideMenuItem(R.string.media_2_title, R.id.media_2, 0)); items.add(new SlideMenuItem(R.string.media_3_title, R.id.media_3, 0)); items.add(new SlideMenuItem(R.string.media_4_title, R.id.media_4, 0)); items.add(new SlideMenuItem(R.string.media_5_title, R.id.media_5, 0)); items.add(new SlideMenuItem(R.string.media_6_title, R.id.media_6, 0)); /* items.add(new SlideMenuCategory(R.string.menu_social)); items.add(new SlideMenuItem(R.string.menu_gplus, R.id.gplus, 0)); items.add(new SlideMenuItem(R.string.menu_facebook, R.id.facebook, 0)); items.add(new SlideMenuItem(R.string.menu_kag, R.id.kag, 0)); items.add(new SlideMenuItem(R.string.menu_kidc, R.id.kidc, 0)); */ } mList = new ListView(this); mAdapter = new SlideMenuAdapter(this, items); mAdapter.setListener(this); mAdapter.setActivePosition(mActivePosition); mList.setAdapter(mAdapter); mList.setOnItemClickListener(mItemClickListener); mDrawer.setMenuView(mList); // Allow the menu to slide out when any part of the screen is dragged. mDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN); // The drawable that replaces the up indicator in the action bar. mDrawer.setSlideDrawable(R.drawable.ic_drawer); // Whether the previous drawable should be shown. mDrawer.setDrawerIndicatorEnabled(true); // Activate type-to-search for local search. Typing will automatically // start a search of the database. setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL); // Register a receiver for the kill order. mKillReceiver = new KillReceiver(); registerReceiver(mKillReceiver, IntentFilter.create(ACTION_KILL, KILL_TYPE)); }
From source file:org.awesomeapp.messenger.ui.ContactListItem.java
public void bind(Cursor cursor, String underLineText, boolean showChatMsg, boolean scrolling) { ViewHolder holder = (ViewHolder) getTag(); if (holder == null) { holder = new ViewHolder(); holder.mLine1 = (TextView) findViewById(R.id.line1); holder.mLine2 = (TextView) findViewById(R.id.line2); holder.mAvatar = (ImageView) findViewById(R.id.avatar); holder.mStatusIcon = (ImageView) findViewById(R.id.statusIcon); holder.mStatusText = (TextView) findViewById(R.id.statusText); //holder.mEncryptionIcon = (ImageView)view.findViewById(R.id.encryptionIcon); holder.mContainer = findViewById(R.id.message_container); // holder.mMediaThumb = (ImageView)findViewById(R.id.media_thumbnail); setTag(holder);/*from www . jav a 2 s . c o m*/ } final long providerId = cursor.getLong(COLUMN_CONTACT_PROVIDER); final String address = cursor.getString(COLUMN_CONTACT_USERNAME); final String displayName = cursor.getString(COLUMN_CONTACT_NICKNAME); final int type = cursor.getInt(COLUMN_CONTACT_TYPE); final String lastMsg = cursor.getString(COLUMN_LAST_MESSAGE); long lastMsgDate = cursor.getLong(COLUMN_LAST_MESSAGE_DATE); final int presence = cursor.getInt(COLUMN_CONTACT_PRESENCE_STATUS); final int subType = cursor.getInt(COLUMN_SUBSCRIPTION_TYPE); final int subStatus = cursor.getInt(COLUMN_SUBSCRIPTION_STATUS); String statusText = cursor.getString(COLUMN_CONTACT_CUSTOM_STATUS); String nickname = displayName; if (nickname == null) { nickname = address.split("@")[0]; } else if (nickname.indexOf('@') != -1) { nickname = nickname.split("@")[0]; } if (!TextUtils.isEmpty(underLineText)) { // highlight/underline the word being searched String lowercase = nickname.toLowerCase(); int start = lowercase.indexOf(underLineText.toLowerCase()); if (start >= 0) { int end = start + underLineText.length(); SpannableString str = new SpannableString(nickname); str.setSpan(new UnderlineSpan(), start, end, Spannable.SPAN_INCLUSIVE_INCLUSIVE); holder.mLine1.setText(str); } else holder.mLine1.setText(nickname); } else holder.mLine1.setText(nickname); /* if (holder.mStatusIcon != null) { Drawable statusIcon = brandingRes.getDrawable(PresenceUtils.getStatusIconId(presence)); //statusIcon.setBounds(0, 0, statusIcon.getIntrinsicWidth(), // statusIcon.getIntrinsicHeight()); holder.mStatusIcon.setImageDrawable(statusIcon);address }*/ holder.mStatusIcon.setVisibility(View.GONE); if (holder.mAvatar != null) { if (Imps.Contacts.TYPE_GROUP == type) { holder.mAvatar.setVisibility(View.VISIBLE); if (AVATAR_DEFAULT_GROUP == null) AVATAR_DEFAULT_GROUP = new RoundedAvatarDrawable( BitmapFactory.decodeResource(getResources(), R.drawable.group_chat)); holder.mAvatar.setImageDrawable(AVATAR_DEFAULT_GROUP); } else if (cursor.getColumnIndex(Imps.Contacts.AVATAR_DATA) != -1) { RoundedAvatarDrawable avatar = null; try { avatar = DatabaseUtils.getAvatarFromCursor(cursor, COLUMN_AVATAR_DATA, ImApp.SMALL_AVATAR_WIDTH, ImApp.SMALL_AVATAR_HEIGHT); } catch (Exception e) { //problem decoding avatar Log.e(ImApp.LOG_TAG, "error decoding avatar", e); } try { if (avatar != null) { setAvatarBorder(presence, avatar); holder.mAvatar.setImageDrawable(avatar); } else { String letterString = null; if (nickname.length() > 0) letterString = nickname.substring(0, 1).toUpperCase(); else letterString = "?"; //the unknown name! int color = getAvatarBorder(presence); int padding = 24; LetterAvatar lavatar = new LetterAvatar(getContext(), color, letterString, padding); holder.mAvatar.setImageDrawable(lavatar); } holder.mAvatar.setVisibility(View.VISIBLE); } catch (OutOfMemoryError ome) { //this seems to happen now and then even on tiny images; let's catch it and just not set an avatar } } else { //holder.mAvatar.setImageDrawable(getContext().getResources().getDrawable(R.drawable.avatar_unknown)); holder.mAvatar.setVisibility(View.GONE); } } holder.mStatusText.setText(""); statusText = address; holder.mLine2.setText(statusText); if (subType == Imps.ContactsColumns.SUBSCRIPTION_TYPE_INVITATIONS) { // if (holder.mLine2 != null) // holder.mLine2.setText("Contact List Request"); } holder.mLine1.setVisibility(View.VISIBLE); }
From source file:com.todoroo.astrid.actfm.ActFmLoginActivity.java
protected SpannableString getLinkStringWithCustomInterval(String base, String linkComponent, int start, int endOffset, final OnClickListener listener) { SpannableString link = new SpannableString(String.format("%s %s", //$NON-NLS-1$ base, linkComponent));//w w w .j a v a2s .co m ClickableSpan linkSpan = new ClickableSpan() { @Override public void onClick(View widget) { listener.onClick(widget); } @Override public void updateDrawState(TextPaint ds) { ds.setUnderlineText(true); ds.setColor(Color.rgb(68, 68, 68)); } }; link.setSpan(linkSpan, start, link.length() + endOffset, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); return link; }