List of usage examples for android.widget TextView setTextColor
@android.view.RemotableViewMethod public void setTextColor(ColorStateList colors)
From source file:com.aniruddhc.acemusic.player.LauncherActivity.LauncherActivity.java
public void showTrialDialog(final boolean expired, int numDaysRemaining) { AlertDialog.Builder builder = new AlertDialog.Builder(mContext); builder.setTitle(R.string.app_name); builder.setCancelable(false);/*from w w w . j a v a2 s.c om*/ View view = this.getLayoutInflater().inflate(R.layout.trial_expiry_dialog, null); TextView trialExpiredText = (TextView) view.findViewById(R.id.trial_message); TextView trialDaysRemaining = (TextView) view.findViewById(R.id.trial_days_remaining); TextView trialDaysCaps = (TextView) view.findViewById(R.id.days_caps); trialExpiredText.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); trialExpiredText .setPaintFlags(trialExpiredText.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); trialDaysRemaining.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); trialDaysCaps.setTypeface(TypefaceHelper.getTypeface(mContext, "RobotoCondensed-Light")); trialDaysCaps .setPaintFlags(trialDaysCaps.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); if (expired) { trialDaysRemaining.setText(R.string.expired); trialExpiredText.setText(R.string.trial_expired); trialDaysRemaining.setTextColor(0xFFFF8800); trialDaysCaps.setVisibility(View.GONE); trialDaysRemaining.setTextSize(36); trialDaysRemaining.setPaintFlags( trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG); } else { trialExpiredText.setText(R.string.trial_running); trialDaysRemaining.setText("" + numDaysRemaining); trialDaysCaps.setVisibility(View.VISIBLE); trialDaysRemaining.setTextColor(0xFF0099CC); trialDaysRemaining.setPaintFlags(trialDaysRemaining.getPaintFlags() | Paint.ANTI_ALIAS_FLAG | Paint.SUBPIXEL_TEXT_FLAG | Paint.FAKE_BOLD_TEXT_FLAG); } builder.setView(view); builder.setPositiveButton(R.string.upgrade, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { showUpgradeFragmentWithPromo(); } }); builder.setNegativeButton(R.string.later, new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (expired) { finish(); } else { launchMainActivity(); } } }); builder.create().show(); }
From source file:com.av.benzandroid.views.SlidingTabLayout.java
/** * Create a default view to be used for tabs. This is called if a custom tab view is not set via * {@link #setCustomTabView(int, int)}.//from w ww . j a v a 2 s .c o m */ protected TextView createDefaultTabView(Context context) { TextView textView = new TextView(context); textView.setGravity(Gravity.CENTER); textView.setTextSize(TypedValue.COMPLEX_UNIT_SP, TAB_VIEW_TEXT_SIZE_SP); textView.setTypeface(Typeface.DEFAULT_BOLD); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { // If we're running on Honeycomb or newer, then we can use the Theme's // selectableItemBackground to ensure that the View has a pressed state TypedValue outValue = new TypedValue(); getContext().getTheme().resolveAttribute(android.R.attr.selectableItemBackground, outValue, true); textView.setBackgroundResource(outValue.resourceId); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { // If we're running on ICS or newer, enable all-caps to match the Action Bar tab style textView.setAllCaps(true); } int padding = (int) (TAB_VIEW_PADDING_DIPS * getResources().getDisplayMetrics().density); textView.setPadding(padding, padding, padding, padding); //Fit tabs in parent view width WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size); textView.setWidth(size.x / mRowCount); textView.setTextColor(DEFAULT_TEXTVIEW_COLOR); // textView.setTextColor(SELECTED_TEXTVIEW_COLOR); return textView; }
From source file:com.sdspikes.fireworks.FireworksActivity.java
private TextView makeAttributeTextView(final int rank, final GameState.CardColor color) { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); int oneButtonWidth = mDiscardWidthR2 / 10; int marginWidth = oneButtonWidth / 10; params.setMargins(marginWidth, 5, marginWidth, 5); params.width = oneButtonWidth - marginWidth * 2; params.height = params.width;//from w w w . j a v a2 s . com TextView textView = new TextView(this); textView.setLayoutParams(params); textView.setText(String.valueOf(rank)); if (rank == -1) textView.setText(" "); textView.setGravity(Gravity.CENTER); textView.setBackgroundResource(HandFragment.cardColorToBGColor.get(color)); textView.setTextColor(getResources().getColor(HandFragment.cardColorToTextColor(color))); textView.setVisibility(View.VISIBLE); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Log.d(TAG, "clicked on an attribute button: " + GameState.Card.cardColorToString(color) + " " + rank); List<GameState.Card> hand = mTurnData.state.hands.get(mRecipientPlayer).hand; List<Integer> locations = new ArrayList<Integer>(); String info = ""; if (rank == -1) { info = GameState.Card.cardColorToString(color); for (int i = 0; i < hand.size(); i++) { if (hand.get(i).color == color) locations.add(i); } } else { info = HandFragment.rankToString(rank); for (int i = 0; i < hand.size(); i++) { if (hand.get(i).rank == rank) locations.add(i); } } if (locations.size() == 0) { Toast.makeText(FireworksActivity.this, mIdToName.get(mRecipientPlayer) + " does not have any " + info, Toast.LENGTH_SHORT); } else { int[] positions = new int[locations.size()]; for (int i = 0; i < positions.length; i++) { // Make the positions 1-indexed positions[i] = locations.get(i) + 1; } LogItem item = new InfoLogItem(mMyId, mRecipientPlayer, info, positions); actionLog.add(item.toString()); mTurnData.state.hintsRemaining--; mTurnData.state.currentPlayerId = mTurnData.state.hands .get(mTurnData.state.currentPlayerId).nextPlayerId; togglePlayOptionsVisible(PlayOptions.turnMessage); broadcastGameInfo(item.getJSONObject()); updateAllPlayers(mTurnData.getJSONObject()); mRecipientPlayer = null; } } }); return textView; }
From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java
private void styleInfoSnackbar() { ViewGroup group = (ViewGroup) snackbar.getView(); group.setBackgroundColor(getResources().getColor(R.color.primary)); snackbar.setActionTextColor(getResources().getColor(R.color.accent)); TextView tv = (TextView) group.findViewById(android.support.design.R.id.snackbar_text); tv.setTextColor(getResources().getColor(R.color.text_on_primary)); }
From source file:com.chatwing.whitelabel.activities.CommunicationActivity.java
private void styleErrorSnackbar() { ViewGroup group = (ViewGroup) snackbar.getView(); group.setBackgroundColor(getResources().getColor(android.R.color.holo_red_light)); snackbar.setActionTextColor(getResources().getColor(R.color.white)); TextView tv = (TextView) group.findViewById(android.support.design.R.id.snackbar_text); tv.setTextColor(getResources().getColor(R.color.white)); }
From source file:com.ichi2.anki.CardEditor.java
private void populateEditFields() { mFieldsLayoutContainer.removeAllViews(); mEditFields = new LinkedList<FieldEditText>(); String[][] fields = mEditorNote.items(); // Use custom font if selected from preferences Typeface mCustomTypeface = null;//from w w w . j a v a 2 s .co m SharedPreferences preferences = AnkiDroidApp.getSharedPrefs(getBaseContext()); String customFont = preferences.getString("browserEditorFont", ""); if (!customFont.equals("")) { mCustomTypeface = AnkiFont.getTypeface(this, customFont); } for (int i = 0; i < fields.length; i++) { FieldEditText newTextbox = new FieldEditText(this, i, fields[i]); if (mCustomTypeface != null) { newTextbox.setTypeface(mCustomTypeface); } TextView label = newTextbox.getLabel(); label.setTextColor(Color.BLACK); label.setPadding((int) UIUtils.getDensityAdjustedValue(this, 3.4f), 0, 0, 0); ImageView circle = newTextbox.getCircle(); mEditFields.add(newTextbox); FrameLayout frame = new FrameLayout(this); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, Gravity.RIGHT | Gravity.CENTER_VERTICAL); params.rightMargin = 10; circle.setLayoutParams(params); frame.addView(newTextbox); frame.addView(circle); mFieldsLayoutContainer.addView(label); mFieldsLayoutContainer.addView(frame); } }
From source file:com.openerp.addons.messages.Message.java
public void setupListView(List<OEListViewRows> message_list) { // Destroying pre-loaded instance and going to create new one lstview = null;//w w w . j av a2 s .c o m // Fetching required messages for listview by filtering of requrement if (list != null && list.size() <= 0) { list = message_list;// getMessages(message_list); } else { rootView.findViewById(R.id.messageSyncWaiter).setVisibility(View.GONE); rootView.findViewById(R.id.txvMessageAllReadMessage).setVisibility(View.GONE); } // Handling List View controls and keys String[] from = new String[] { "subject|type", "body", "starred", "author_id|email_from", "date", "model|type" }; int[] to = new int[] { R.id.txvMessageSubject, R.id.txvMessageBody, R.id.imgMessageStarred, R.id.txvMessageFrom, R.id.txvMessageDate, R.id.txvMessageTag }; // Creating instance for listAdapter listAdapter = new OEListViewAdapter(scope.context(), R.layout.message_listview_items, list, from, to, db, true, new int[] { R.drawable.message_listview_bg_toread_selector, R.drawable.message_listview_bg_tonotread_selector }, "to_read"); // Telling adapter to clean HTML text for key value listAdapter.cleanHtmlToTextOn("body"); listAdapter.cleanDate("date", scope.User().getTimezone()); // Setting callback handler for boolean field value change. listAdapter.setBooleanEventOperation("starred", R.drawable.ic_action_starred, R.drawable.ic_action_unstarred, updateStarred); listAdapter.addViewListener(new OEListViewOnCreateListener() { @Override public View listViewOnCreateListener(int position, View row_view, OEListViewRows row_data) { String model_name = row_data.getRow_data().get("model").toString(); String model = model_name; String res_id = row_data.getRow_data().get("res_id").toString(); if (model_name.equals("false")) { model_name = capitalizeString(row_data.getRow_data().get("type").toString()); } else { String[] model_parts = TextUtils.split(model_name, "\\."); HashSet unique_parts = new HashSet(Arrays.asList(model_parts)); model_name = capitalizeString(TextUtils.join(" ", unique_parts.toArray())); } TextView msgTag = (TextView) row_view.findViewById(R.id.txvMessageTag); int tag_color = 0; if (message_model_colors.containsKey(model_name)) { tag_color = message_model_colors.get(model_name); } else { tag_color = Color.parseColor(tag_colors[tag_color_count]); message_model_colors.put(model_name, tag_color); tag_color_count++; if (tag_color_count > tag_colors.length) { tag_color_count = 0; } } if (model.equals("mail.group")) { if (UserGroups.group_names.containsKey("group_" + res_id)) { model_name = UserGroups.group_names.get("group_" + res_id); tag_color = UserGroups.menu_color.get("group_" + res_id); } } msgTag.setBackgroundColor(tag_color); msgTag.setText(model_name); TextView txvSubject = (TextView) row_view.findViewById(R.id.txvMessageSubject); TextView txvAuthor = (TextView) row_view.findViewById(R.id.txvMessageFrom); if (row_data.getRow_data().get("to_read").toString().equals("false")) { txvSubject.setTypeface(null, Typeface.NORMAL); txvSubject.setTextColor(Color.BLACK); txvAuthor.setTypeface(null, Typeface.NORMAL); txvAuthor.setTextColor(Color.BLACK); } else { txvSubject.setTypeface(null, Typeface.BOLD); txvSubject.setTextColor(Color.parseColor("#414141")); txvAuthor.setTypeface(null, Typeface.BOLD); txvAuthor.setTextColor(Color.parseColor("#414141")); } return row_view; } }); // Creating instance for listview control lstview = (ListView) rootView.findViewById(R.id.lstMessages); // Providing adapter to listview scope.context().runOnUiThread(new Runnable() { @Override public void run() { lstview.setAdapter(listAdapter); } }); // Setting listview choice mode to multiple model lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL); // Seeting item long click listern to activate action mode. lstview.setOnItemLongClickListener(new OnItemLongClickListener() { @Override public boolean onItemLongClick(AdapterView<?> arg0, View view, int index, long arg3) { // TODO Auto-generated method stub OEListViewRows data = (OEListViewRows) lstview.getAdapter().getItem(index); Toast.makeText(scope.context(), data.getRow_id() + " id clicked", Toast.LENGTH_LONG).show(); view.setSelected(true); if (mActionMode != null) { return false; } // Start the CAB using the ActionMode.Callback defined above mActionMode = scope.context().startActionMode(mActionModeCallback); selectedCounter++; view.setBackgroundResource(R.drawable.listitem_pressed); // lstview.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); return true; } }); // Setting multi choice selection listener lstview.setMultiChoiceModeListener(new MultiChoiceModeListener() { HashMap<Integer, Boolean> selectedList = new HashMap<Integer, Boolean>(); @Override public void onItemCheckedStateChanged(ActionMode mode, int position, long id, boolean checked) { // Here you can do something when items are // selected/de-selected, // such as update the title in the CAB selectedList.put(position, checked); if (checked) { selectedCounter++; } else { selectedCounter--; } if (selectedCounter != 0) { mode.setTitle(selectedCounter + ""); } } @Override public boolean onActionItemClicked(ActionMode mode, MenuItem item) { // Respond to clicks on the actions in the CAB HashMap<Integer, Integer> msg_pos = new HashMap<Integer, Integer>(); OEDialog dialog = null; switch (item.getItemId()) { case R.id.menu_message_mark_unread_selected: Log.e("menu_message_context", "Mark as Unread"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_mark_read_selected: Log.e("menu_message_context", "Mark as Read"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, true); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_move_to_archive_selected: Log.e("menu_message_context", "Archive"); for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } readunreadoperation = new PerformReadUnreadArchiveOperation(msg_pos, false); readunreadoperation.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_add_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, true); markasTodoTask.execute((Void) null); mode.finish(); return true; case R.id.menu_message_more_remove_star_selected: for (int pos : selectedList.keySet()) { msg_pos.put(list.get(pos).getRow_id(), pos); } markasTodoTask = new PerformOperation(msg_pos, false); markasTodoTask.execute((Void) null); mode.finish(); return true; default: return false; } } @Override public boolean onCreateActionMode(ActionMode mode, Menu menu) { // Inflate the menu for the CAB MenuInflater inflater = mode.getMenuInflater(); inflater.inflate(R.menu.menu_fragment_message_context, menu); return true; } @Override public void onDestroyActionMode(ActionMode mode) { // Here you can make any necessary updates to the activity when // the CAB is removed. By default, selected items are // deselected/unchecked. /* * Perform Operation on Selected Ids. * * row_ids are list of selected message Ids. */ selectedList.clear(); selectedCounter = 0; lstview.clearChoices(); } @Override public boolean onPrepareActionMode(ActionMode mode, Menu menu) { // Here you can perform updates to the CAB due to // an invalidate() request return false; } }); lstview.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View view, int index, long id) { // TODO Auto-generated method stub MessageDetail messageDetail = new MessageDetail(); Bundle bundle = new Bundle(); bundle.putInt("message_id", list.get(index).getRow_id()); bundle.putInt("position", index); messageDetail.setArguments(bundle); scope.context().fragmentHandler.setBackStack(true, null); scope.context().fragmentHandler.replaceFragmnet(messageDetail); if (!type.equals("archive")) { list.remove(index); } listAdapter.refresh(list); } }); // Getting Pull To Refresh Attacher from Main Activity mPullToRefreshAttacher = scope.context().getPullToRefreshAttacher(); // Set the Refreshable View to be the ListView and the refresh listener // to be this. if (mPullToRefreshAttacher != null & lstview != null) { mPullToRefreshAttacher.setRefreshableView(lstview, this); } }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
private int setupWordViewsAndReturnStartIndexOfMoreSuggestions(final SuggestedWords suggestedWords, final int maxSuggestionInStrip) { // Clear all suggestions first for (int positionInStrip = 0; positionInStrip < maxSuggestionInStrip; ++positionInStrip) { final TextView wordView = mWordViews.get(positionInStrip); wordView.setText(null);// w w w .ja v a 2 s. c om wordView.setTag(null); // Make this inactive for touches in {@link #layoutWord(int,int)}. if (SuggestionStripView.DBG) { mDebugInfoViews.get(positionInStrip).setText(null); } } int count = 0; int indexInSuggestedWords; for (indexInSuggestedWords = 0; indexInSuggestedWords < suggestedWords.size() && count < maxSuggestionInStrip; indexInSuggestedWords++) { final int positionInStrip = getPositionInSuggestionStrip(indexInSuggestedWords, suggestedWords); if (positionInStrip < 0) { continue; } final TextView wordView = mWordViews.get(positionInStrip); // {@link TextView#getTag()} is used to get the index in suggestedWords at // {@link SuggestionStripView#onClick(View)}. wordView.setTag(indexInSuggestedWords); wordView.setText(getStyledSuggestedWord(suggestedWords, indexInSuggestedWords)); wordView.setTextColor(getSuggestionTextColor(suggestedWords, indexInSuggestedWords)); if (SuggestionStripView.DBG) { mDebugInfoViews.get(positionInStrip).setText(suggestedWords.getDebugString(indexInSuggestedWords)); } count++; } return indexInSuggestedWords; }
From source file:com.adithya321.sharesanalysis.fragments.DetailFragment.java
private void setShareSales(View view) { TextView totalSharesPurchasedTV = (TextView) view.findViewById(R.id.detail_total_shares_sold); TextView totalValueTV = (TextView) view.findViewById(R.id.detail_total_value_sold); TextView targetSalePriceTV = (TextView) view.findViewById(R.id.detail_target); TextView differenceTV = (TextView) view.findViewById(detail_difference); int totalSharesSold = 0; int totalSharesPurchased = 0; double totalValueSold = 0; double totalValuePurchased = 0; double averageShareValue = 0; double targetSalePrice = 0; double difference = 0; RealmList<Purchase> purchases = share.getPurchases(); for (Purchase purchase : purchases) { if (purchase.getType().equals("sell")) { totalSharesSold += purchase.getQuantity(); totalValueSold += (purchase.getQuantity() * purchase.getPrice()); } else if (purchase.getType().equals("buy")) { totalSharesPurchased += purchase.getQuantity(); totalValuePurchased += (purchase.getQuantity() * purchase.getPrice()); }//from w w w. ja v a 2 s . c om } if (totalSharesPurchased != 0) averageShareValue = totalValuePurchased / totalSharesPurchased; Date today = new Date(); Date start = share.getDateOfInitialPurchase(); long noOfDays = DateUtils.getDateDiff(start, today, TimeUnit.DAYS); SharedPreferences sharedPreferences = getActivity().getSharedPreferences("prefs", 0); double target = sharedPreferences.getFloat("target", 0); targetSalePrice = averageShareValue * Math.pow((1 + (target / 100)), ((double) noOfDays / 365)); difference = share.getCurrentShareValue() - targetSalePrice; if (difference < 0) differenceTV.setTextColor(getResources().getColor((android.R.color.holo_red_dark))); else differenceTV.setTextColor(getResources().getColor((R.color.colorPrimary))); totalSharesPurchasedTV.setText(String.valueOf(totalSharesSold)); totalValueTV.setText(String.valueOf(NumberUtils.round(totalValueSold, 2))); targetSalePriceTV.setText(String.valueOf(NumberUtils.round(targetSalePrice, 2))); differenceTV.setText(String.valueOf(NumberUtils.round(difference, 2))); }