List of usage examples for android.widget TextView setTag
public void setTag(final Object tag)
From source file:com.inmobi.ultrapush.AnalyzeActivity.java
private ArrayAdapter<String> popupMenuAdapter(String itemTagArray[]) { ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, itemTagArray) {/* w ww. j a va 2s .c o m*/ @Override public View getView(int position, View convertView, ViewGroup parent) { // setting the ID and text for every items in the list String item = getItem(position); String[] itemArr = item.split("::"); String text = itemArr[0]; String id = itemArr[1]; // visual settings for the list item TextView listItem = new TextView(AnalyzeActivity.this); if (id.equals("0")) { listItem.setText(text); listItem.setTag(id); listItem.setTextSize(listItemTitleTextSize / DPRatio); listItem.setPadding(5, 5, 5, 5); listItem.setTextColor(Color.GREEN); listItem.setGravity(android.view.Gravity.CENTER); } else { listItem.setText(text); listItem.setTag(id); listItem.setTextSize(listItemTextSize / DPRatio); listItem.setPadding(5, 5, 5, 5); listItem.setTextColor(Color.WHITE); listItem.setGravity(android.view.Gravity.CENTER); } return listItem; } }; return adapter; }
From source file:es.usc.citius.servando.calendula.fragments.ScheduleImportFragment.java
private void setupScheduleEntrySpinners(final View entryView, ScheduleItem scheduleItem, String[] routineNames) {//from w w w . j a v a 2 s . c o m final Spinner routineSpinner = (Spinner) entryView.findViewById(R.id.entry_routine_spinner); final TextView doseTv = (TextView) entryView.findViewById(R.id.entry_dose_textview); // final Spinner doseSpinner = (Spinner) entryView.findViewById(R.id.entry_dose_spinner); doseTv.setTag(scheduleItem); routineSpinner.setTag(scheduleItem); // set up the routine selection adapter updateRoutineSelectionAdapter(entryView, routineSpinner, routineNames); if (scheduleItem != null && scheduleItem.routine() != null) { String routineName = scheduleItem.routine().name(); int index = Arrays.asList(routineNames).indexOf(routineName); routineSpinner.setSelection(index); } else { routineSpinner.setSelection(routineNames.length - 1); } doseTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { showDosePickerDialog((ScheduleItem) v.getTag(), (TextView) v); } }); doseTv.setText(scheduleItem.displayDose()); // setup listeners routineSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { String selected = (String) adapterView.getItemAtPosition(i); Routine r = Routine.findByName(selected); ScheduleItem item = ((ScheduleItem) routineSpinner.getTag()); if (r != null) { updateEntryTime(r, entryView); } else { updateEntryTime(null, entryView); showAddNewRoutineDialog(entryView); } Log.d(TAG, "Updated routine to " + (r != null ? r.name() : "NULL") + " on item " + item.getId()); item.setRoutine(r); logScheduleItems(); } @Override public void onNothingSelected(AdapterView<?> adapterView) { } }); routineSpinner.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { if (motionEvent.getAction() == MotionEvent.ACTION_UP) { if (((String) routineSpinner.getSelectedItem()) .equalsIgnoreCase(getString(R.string.create_new_routine))) { showAddNewRoutineDialog(entryView); return true; } } return false; } }); }
From source file:com.cssweb.android.base.QuoteGridActivity.java
private void AddViewItem(String paramString, int paramInt1, LinearLayout paramLinearLayout, int paramInt2, int paramInt3, int paramInt4, boolean paramBoolean) { TextView localTextView = new TextView(this); float f = this.mFontSize; localTextView.setTextSize(f);/*from ww w . j av a 2 s. com*/ //??4? if (paramInt2 == paramInt4 && paramInt3 == 0 && nameOrcode) { if (this.mPaint.measureText(paramString) > textWeight) localTextView.setTextSize(13); } if (n2 == paramInt2) { String str = (n1 == 0) ? paramString + low : (n1 == 1) ? paramString + top : paramString; localTextView.setText(str); } else { localTextView.setText(paramString); } localTextView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); localTextView.setFocusable(paramBoolean); localTextView.setOnClickListener(mClickListener); localTextView.setOnLongClickListener(mLongClickListener); localTextView.setOnTouchListener(this); //touch localTextView.setTag(paramInt2); localTextView.setEnabled(paramBoolean); localTextView.setSingleLine(false); if (paramInt4 == 0 && paramInt3 >= 0) {// localTextView.setGravity(Gravity.CENTER); int i1 = this.residTitleCol; int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(i1); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[2]); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residTitleScrollCol[1]); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residTitleScrollCol[0]); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + CssSystem.getTableTitleHeight(this)); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } if (paramInt4 != 0 && paramInt3 >= 0) { int i8 = 0; localTextView.setTextColor(paramInt1); if (paramInt3 == 0) { localDrawable = getResources().getDrawable(this.residCol); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 100) { localDrawable = getResources().getDrawable(this.residScrollCol[2]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else if (paramInt3 == 13) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 20; //localTextView.setWidth(i8+20); } else if (paramInt3 == 8) { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); i8 += 10; //localTextView.setWidth(i8+20); } else if (paramInt3 % 2 == 0) { localDrawable = getResources().getDrawable(this.residScrollCol[1]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } else { localDrawable = getResources().getDrawable(this.residScrollCol[0]); localTextView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); i8 = localDrawable.getIntrinsicWidth(); } localTextView.setBackgroundDrawable(localDrawable); int i6 = localDrawable.getIntrinsicHeight(); localTextView.setHeight(i6 + rowHeight); //int i9 = (int) Math.max(i8, mPaint.measureText(paramString)); localTextView.setWidth(i8); paramLinearLayout.addView(localTextView); return; } // if ((paramInt3 == j) && (paramInt4 == l)) { // int i13 = this.residTitleScrollCol[l]; // localDrawable = localResources.getDrawable(i13); // localTextView.setTextColor(paramInt1); // localTextView.setBackgroundDrawable(localDrawable); // paramLinearLayout.addView(localTextView); // return; // } }
From source file:com.github.irshulx.Components.InputExtensions.java
public void updateTextColor(String color, TextView editText) { try {//w ww . j a va 2s . co m if (color.contains("rgb")) { Pattern c = Pattern.compile("rgb *\\( *([0-9]+), *([0-9]+), *([0-9]+) *\\)"); Matcher m = c.matcher(color); if (m.matches()) { int r = Integer.parseInt(m.group(1)); int g = Integer.parseInt(m.group(2)); int b = Integer.parseInt(m.group(3)); color = String.format(Locale.getDefault(), "#%02X%02X%02X", r, g, b); } } if (editText == null) { editText = (EditText) editorCore.getActiveView(); } EditorControl tag = editorCore.getControlTag(editText); if (tag.textSettings == null) tag.textSettings = new TextSettings(color); else tag.textSettings.setTextColor(color); editText.setTag(tag); editText.setTextColor(Color.parseColor(color)); } catch (Exception ex) { Log.e(editorCore.TAG, ex.getMessage()); } }
From source file:com.github.irshulx.Components.InputExtensions.java
private void updateTextStyle(TextView editText, EditorTextStyle editorTextStyle) { EditorControl tag;/*from w w w .j ava 2 s.c om*/ if (editText == null) { editText = (EditText) editorCore.getActiveView(); } EditorControl editorControl = editorCore.getControlTag(editText); if (isEditorTextStyleHeaders(editorTextStyle)) { if (editorCore.containsStyle(editorControl.editorTextStyles, editorTextStyle)) { editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, NORMALTEXTSIZE); editText.setTypeface(getTypeface(CONTENT, Typeface.NORMAL)); tag = reWriteTags(editorControl, EditorTextStyle.NORMAL); } else { editText.setTextSize(TypedValue.COMPLEX_UNIT_SP, getTextStyleFromStyle(editorTextStyle)); editText.setTypeface(getTypeface(HEADING, Typeface.BOLD)); tag = reWriteTags(editorControl, editorTextStyle); } editText.setTag(tag); } }
From source file:com.money.manager.ex.transactions.EditTransactionCommonFunctions.java
private void displayAmountFormatted(TextView view, Money amount, Integer currencyId) { if (amount == null) return;/*from w w w.java 2 s. c o m*/ if (currencyId == null || currencyId == Constants.NOT_SET) return; CurrencyService currencyService = new CurrencyService(getContext()); String amountDisplay = currencyService.getCurrencyFormatted(currencyId, amount); view.setText(amountDisplay); view.setTag(amount.toString()); }
From source file:com.github.irshulx.Components.InputExtensions.java
public void boldifyText(EditorControl tag, TextView editText, int textMode) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.NORMAL)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete); tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.ITALIC)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert); tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC)); } else {/*from w w w . j a v a 2 s . c om*/ tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.BOLD)); } editText.setTag(tag); }
From source file:com.github.irshulx.Components.InputExtensions.java
public void italicizeText(EditorControl tag, TextView editText, int textMode) { if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.ITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.NORMAL)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLDITALIC)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Delete); tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.BOLD)); } else if (editorCore.containsStyle(tag.editorTextStyles, EditorTextStyle.BOLD)) { tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLDITALIC, Op.Insert); tag = editorCore.updateTagStyle(tag, EditorTextStyle.BOLD, Op.Delete); editText.setTypeface(getTypeface(textMode, Typeface.BOLD_ITALIC)); } else {//from ww w . ja v a 2 s .c om tag = editorCore.updateTagStyle(tag, EditorTextStyle.ITALIC, Op.Insert); editText.setTypeface(getTypeface(textMode, Typeface.ITALIC)); } editText.setTag(tag); }
From source file:pro.dbro.bart.TheActivity.java
public void displayEtdResponse(etdResponse etdResponse) { if (timer != null) timer.cancel(); // cancel previous timer long now = new Date().getTime(); timerViews = new ArrayList(); // release old ETA text views maxTimer = 0; // reset maxTimer fareTv.setText(""); fareTv.setVisibility(View.GONE); tableLayout.removeAllViews();// w w w . j a v a 2 s . c o m String lastDestination = ""; // Display the alert ImageView and create a click listener to display alert html if (etdResponse.message != null) { // If the response message matches the response for a closed station, // Display "Closed for tonight" and time of next train, if available. if (etdResponse.message.contains("No data matched your criteria.")) { String message = "This station is closed for tonight"; TextView specialScheduleTextView = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTextView.setPadding(0, 0, 0, 0); if (etdResponse.etds != null && etdResponse.etds.size() > 0) { Date nextTrain = new Date(etdResponse.date.getTime() + ((etd) etdResponse.etds.get(0)).minutesToArrival * 60 * 1000); SimpleDateFormat sdf = new SimpleDateFormat("KK:MM a"); message += ". Next train at " + sdf.format(nextTrain); } specialScheduleTextView.setText(message); tableLayout.addView(specialScheduleTextView); } else { // Create an imageview that spawns an alertDialog with BART message ImageView specialScheduleImageView = (ImageView) View.inflate(c, R.layout.specialschedulelayout, null); // Tag the specialScheduleImageView with the message html specialScheduleImageView.setTag(Html.fromHtml(etdResponse.message)); // Set the OnClickListener for the specialScheduleImageView to display the tagged message html specialScheduleImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { TextView specialScheduleTv = (TextView) View.inflate(c, R.layout.tabletext, null); specialScheduleTv.setPadding(0, 0, 0, 0); specialScheduleTv.setText(Html.fromHtml(arg0.getTag().toString())); specialScheduleTv.setTextSize(16); specialScheduleTv.setMovementMethod(LinkMovementMethod.getInstance()); new AlertDialog.Builder(c).setTitle("Station Alerts").setIcon(R.drawable.warning) .setView(specialScheduleTv).setPositiveButton("Bummer", null).show(); } }); tableLayout.addView(specialScheduleImageView); } } TableRow tr = (TableRow) View.inflate(c, R.layout.tablerow_right, null); LinearLayout destinationRow = (LinearLayout) View.inflate(c, R.layout.destination_row, null); //TextView timeTv =(TextView) View.inflate(c, R.layout.tabletext, null); int numAlt = 0; for (int x = 0; x < etdResponse.etds.size(); x++) { if (etdResponse.etds.get(x) == null) break; etd thisEtd = (etd) etdResponse.etds.get(x); if (thisEtd.destination != lastDestination) { // new train destination numAlt = 0; tr = (TableRow) View.inflate(c, R.layout.tablerow_right, null); tr.setPadding(0, 0, 10, 0); destinationRow = (LinearLayout) View.inflate(c, R.layout.destination_row, null); TextView destinationTv = (TextView) View.inflate(c, R.layout.destinationlayout, null); if (x == 0) destinationTv.setPadding(0, 0, 0, 0); //bullet.setWidth(200); //destinationTv.setPadding(0, 0, 0, 0); destinationTv.setTextSize(28); destinationTv.setText(thisEtd.destination); TextView timeTv = (TextView) View.inflate(c, R.layout.tabletext, null); // Display eta less than 1m as "<1" if (thisEtd.minutesToArrival == 0) timeTv.setText("<1"); else timeTv.setText(String.valueOf(thisEtd.minutesToArrival)); timeTv.setSingleLine(false); timeTv.setTextSize(36); //timeTv.setPadding(30, 0, 0, 0); long counterTime = thisEtd.minutesToArrival * 60 * 1000; if (counterTime > maxTimer) { maxTimer = counterTime; } timeTv.setTag(counterTime + now); timerViews.add(timeTv); //new ViewCountDownTimer(timeTv, counterTime, 60*1000).start(); //text.setWidth(120); destinationRow.addView(destinationTv); //tr.addView(destinationTv); tr.addView(timeTv); tr.setTag(thisEtd); tableLayout.addView(destinationRow); tableLayout.addView(tr); tr.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { int index = tableLayout.indexOfChild(arg0); // index of clicked view. Expanded view will always be +1 etd thisEtd = (etd) arg0.getTag(); if (!thisEtd.isExpanded) { // if route not expanded thisEtd.isExpanded = true; LinearLayout routeDetail = (LinearLayout) View.inflate(c, R.layout.routedetail, null); TextView platformTv = (TextView) View.inflate(c, R.layout.tabletext, null); platformTv.setPadding(0, 0, 0, 0); platformTv.setText("platform " + thisEtd.platform); platformTv.setTextSize(20); routeDetail.addView(platformTv); ImageView bikeIv = (ImageView) View.inflate(c, R.layout.bikeimage, null); if (!thisEtd.bikes) bikeIv.setImageResource(R.drawable.no_bicycle); routeDetail.addView(bikeIv); tableLayout.addView(routeDetail, index + 1); } else { thisEtd.isExpanded = false; tableLayout.removeViewAt(index + 1); } } }); } else { // append next trains arrival time to existing destination display //timeTv.append(String.valueOf(", "+thisEtd.minutesToArrival)); numAlt++; TextView nextTimeTv = (TextView) View.inflate(c, R.layout.tabletext, null); //nextTimeTv.setTextSize(36-(5*numAlt)); nextTimeTv.setTextSize(36); nextTimeTv.setText(String.valueOf(thisEtd.minutesToArrival)); //nextTimeTv.setPadding(30, 0, 0, 0); if (numAlt == 1) //0xFFF06D2F C9C7C8 nextTimeTv.setTextColor(0xFFC9C7C8); else if (numAlt == 2) nextTimeTv.setTextColor(0xFFA8A7A7); long counterTime = thisEtd.minutesToArrival * 60 * 1000; nextTimeTv.setTag(counterTime + now); if (counterTime > maxTimer) { maxTimer = counterTime; } timerViews.add(nextTimeTv); //new ViewCountDownTimer(nextTimeTv, counterTime, 60*1000).start(); tr.addView(nextTimeTv); } lastDestination = thisEtd.destination; } // end for //scrolly.scrollTo(0, 0); // Avoid spamming bart.gov. Only re-ping if etd response is valid for at least 3m if (maxTimer > 1000 * 60 * 3) { timer = new ViewCountDownTimer(timerViews, "etd", maxTimer, 30 * 1000); timer.start(); } }
From source file:com.nadmm.airports.afd.AirportDetailsFragment.java
protected void addRunwayRow(LinearLayout layout, Cursor c) { String siteNumber = c.getString(c.getColumnIndex(Runways.SITE_NUMBER)); String runwayId = c.getString(c.getColumnIndex(Runways.RUNWAY_ID)); int length = c.getInt(c.getColumnIndex(Runways.RUNWAY_LENGTH)); int width = c.getInt(c.getColumnIndex(Runways.RUNWAY_WIDTH)); String surfaceType = c.getString(c.getColumnIndex(Runways.SURFACE_TYPE)); String baseId = c.getString(c.getColumnIndex(Runways.BASE_END_ID)); String reciprocalId = c.getString(c.getColumnIndex(Runways.RECIPROCAL_END_ID)); String baseRP = c.getString(c.getColumnIndex(Runways.BASE_END_RIGHT_TRAFFIC)); String reciprocalRP = c.getString(c.getColumnIndex(Runways.RECIPROCAL_END_RIGHT_TRAFFIC)); String rp = null;//from w w w. j a v a 2s .c o m if (baseRP.equals("Y") && reciprocalRP.equals("Y")) { rp = " (RP)"; } else if (baseRP.equals("Y")) { rp = " (RP " + baseId + ")"; } else if (reciprocalRP.equals("Y")) { rp = " (RP " + reciprocalId + ")"; } int heading = c.getInt(c.getColumnIndex(Runways.BASE_END_HEADING)); if (heading > 0) { heading = (int) GeoUtils.applyDeclination(heading, mDeclination); } else { // Actual heading is not available, try to deduce it from runway id heading = DataUtils.getRunwayHeading(runwayId); } RelativeLayout row = (RelativeLayout) inflate(R.layout.runway_detail_item); TextView tv = (TextView) row.findViewById(R.id.runway_id); tv.setText(runwayId); UiUtils.setRunwayDrawable(getActivity(), tv, runwayId, length, heading); if (rp != null) { tv = (TextView) row.findViewById(R.id.runway_rp); tv.setText(rp); tv.setVisibility(View.VISIBLE); } tv = (TextView) row.findViewById(R.id.runway_size); tv.setText( String.format(Locale.US, "%s x %s", FormatUtils.formatFeet(length), FormatUtils.formatFeet(width))); tv = (TextView) row.findViewById(R.id.runway_surface); tv.setText(DataUtils.decodeSurfaceType(surfaceType)); if (!runwayId.startsWith("H")) { // Save the textview and runway info for later use tv = (TextView) row.findViewById(R.id.runway_wind_info); Bundle tag = new Bundle(); tag.putString(Runways.BASE_END_ID, baseId); tag.putString(Runways.RECIPROCAL_END_ID, reciprocalId); tag.putInt(Runways.BASE_END_HEADING, heading); tv.setTag(tag); mRunwayViews.add(tv); } Bundle args = new Bundle(); args.putString(Runways.SITE_NUMBER, siteNumber); args.putString(Runways.RUNWAY_ID, runwayId); addClickableRow(layout, row, RunwaysFragment.class, args); }