List of usage examples for android.widget TextView setTag
public void setTag(final Object tag)
From source file:com.gh4a.IssueLabelListActivity.java
private void unselectLabel(TextView tvLabel, View viewColor, String color) { final Typeface condensed = getApplicationContext().condensed; tvLabel.setTag(color); tvLabel.setBackgroundColor(0);//from w ww . j a v a 2s .c om if (Gh4Application.THEME == R.style.LightTheme) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } tvLabel.setTypeface(condensed); viewColor.setBackgroundColor(Color.parseColor("#" + color)); }
From source file:com.hobby.uiframework.widget.PagerSlidingTab.java
private void addTextTab(final int position, String title) { TextView tab = new TextView(getContext()); tab.setText(title);//from w w w . j av a 2 s.c om tab.setGravity(Gravity.CENTER); tab.setSingleLine(); tab.setTag(title + position); addTab(position, tab); }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * Recording time ASYNCHRONOUSLY//from w ww . j a va 2 s. c o m * * @param v */ public void onClickRecord(View v) { LinearLayout llTimePicker = (LinearLayout) v.getParent(); LinearLayout lllFrag = (LinearLayout) llTimePicker.getParent(); LinearLayout llTime = (LinearLayout) llTimePicker.findViewById(R.id.llTimePicker); TimePicker tp = (TimePicker) llTime.findViewById(R.id.tpTask); Integer oiHour = tp.getCurrentHour(); Integer oiMin = tp.getCurrentMinute(); DateUtils du = new DateUtils(); long lmills = du.toMills(oiHour, oiMin); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckIn = new Date().getTime(); long lCheckOut = lCheckIn + lmills; // Save data into both databases Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_ASYNCHRONOUS); recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT) .show(); }
From source file:galilei.kelimekavanozu.activity.PoemBuilderActivity.java
private void shuffleWords() { wordsContainer.removeAllViews();/*from w w w. j a v a 2 s . c om*/ final List<String> wordList = wordBank.loadWords(); for (String w : wordList) { final TextView wordView = (TextView) getLayoutInflater().inflate(R.layout.word, null, true); wordView.setText(w); wordView.setOnTouchListener(new WordTouchListener()); wordView.setTag(w); wordsContainer.addView(wordView); } Crashlytics.setInt(App.CRASHLYTICS_KEY_WORDBANK_COUNT, wordList.size()); }
From source file:com.github.mobile.util.HttpImageGetter.java
private HttpImageGetter show(final TextView view, final CharSequence html, final Object id) { if (TextUtils.isEmpty(html)) return hide(view, id); view.setText(html);//from w ww . ja v a 2s. c om view.setVisibility(VISIBLE); view.setTag(null); return this; }
From source file:com.gh4a.activities.IssueCreateActivity.java
public void fillLabels(List<Label> labels) { Gh4Application app = Gh4Application.get(this); LinearLayout labelLayout = (LinearLayout) findViewById(R.id.ll_labels); for (final Label label : labels) { final View rowView = getLayoutInflater().inflate(R.layout.row_issue_create_label, null); View viewColor = rowView.findViewById(R.id.view_color); viewColor.setBackgroundColor(Color.parseColor("#" + label.getColor())); final TextView tvLabel = (TextView) rowView.findViewById(R.id.tv_title); tvLabel.setTypeface(app.condensed); tvLabel.setText(label.getName()); tvLabel.setOnClickListener(this); tvLabel.setTag(label); if (isInEditMode()) { handleLabelClick(tvLabel, label, mSelectedLabels.contains(label)); }//from w ww . jav a2 s . c o m labelLayout.addView(rowView); } }
From source file:org.ale.scanner.zotero.EditItemActivity.java
private void fillForm() { // Clear any previous data from the form LinearLayout container = ((LinearLayout) findViewById(R.id.editContainer)); container.removeAllViews();//from w ww. j a v a 2 s . c o m // Get the JSON we'll be working from. JSONObject info = mWorkingItem.getSelectedInfo(); final String[] fields; // XXX: temporary hack. In-order list of fields if (ItemType.book.equals(info.optString(ItemField.itemType))) { fields = new String[] { "title", "creators", "abstractNote", "series", "seriesNumber", "volume", "numberOfVolumes", "edition", "place", "publisher", "date", "numPages", "language", "ISBN", "shortTitle", "url", "accessDate", "archive", "archiveLocation", "libraryCatalog", "callNumber", "rights", "extra", "notes", "tags" }; } else { // XXX: Assumes journalArticle fields = new String[] { "title", "creators", "abstractNote", "publicationTitle", "volume", "issue", "pages", "date", "series", "seriesTitle", "seriesText", "journalAbbreviation", "language", "DOI", "ISSN", "shortTitle", "url", "accessDate", "archive", "archiveLocation", "libraryCatalog", "callNumber", "rights", "extra", "tags", "notes" }; } LinearLayout row; LinearLayout crow; int row_ctr = 0; for (String field : fields) { if (field.equals(ItemField.itemType)) continue; if (field.equals(ItemField.creators)) { row = mCreatorList = (LinearLayout) mInflater.inflate(R.layout.edit_creators, container, false); JSONArray creators = info.optJSONArray(field); if (creators == null || creators.length() == 0) { addCreator(); // Empty creator row for new creators } else { for (int c = 0; c < creators.length(); c++) { JSONObject creator = creators.optJSONObject(c); if (creator == null) continue; crow = addCreator(); Spinner sp = (Spinner) crow.findViewById(R.id.creator_type); EditText et = (EditText) crow.findViewById(R.id.creator); String curtype = creator.optString(CreatorType.type); int selection = CreatorType.Book.indexOf(curtype); sp.setSelection(selection >= 0 ? selection : 0); String name = creator.optString(ItemField.Creator.name); if (TextUtils.isEmpty(name)) { String[] firstlast = { creator.optString(ItemField.Creator.firstName), creator.optString(ItemField.Creator.lastName) }; name = TextUtils.join(" ", firstlast); } et.setText(name); } } } else if (field.equals(ItemField.notes)) { row = mNoteList = (LinearLayout) mInflater.inflate(R.layout.edit_notes, container, false); JSONArray notes = info.optJSONArray(field); if (notes == null || notes.length() == 0) { addNote(); // Empty note row for new notes } else { for (int c = 0; c < notes.length(); c++) { JSONObject note = notes.optJSONObject(c); if (note == null) continue; crow = addNote(); EditText et = (EditText) crow.findViewById(R.id.content); et.setText(note.optString(ItemField.Note.note)); } } } else if (field.equals(ItemField.tags)) { row = mTagList = (LinearLayout) mInflater.inflate(R.layout.edit_tags, container, false); JSONArray tags = info.optJSONArray(field); if (tags == null || tags.length() == 0) { addTag(); // Empty tag row for new tags } else { for (int c = 0; c < tags.length(); c++) { JSONObject tag = tags.optJSONObject(c); if (tag == null) continue; crow = addTag(); EditText et = (EditText) crow.findViewById(R.id.content); et.setText(tag.optString(ItemField.Tag.tag)); } } } else { row = (LinearLayout) mInflater.inflate(R.layout.edit_field, container, false); TextView tv_lbl = (TextView) row.findViewById(R.id.label); EditText et = (EditText) row.findViewById(R.id.content); tv_lbl.setText(ItemField.Localized.get(field)); tv_lbl.setTag(field); et.setText(info.optString(field)); } container.addView(row); setRowColor(row, row_ctr); row_ctr++; } }
From source file:org.ounl.lifelonglearninghub.learntracker.gis.ou.swipe.TimeLineActivity.java
/** * On click image view to start stop recording * //from www . ja v a 2 s .c o m * Records time SYNCHRONOUSLY * * @param v */ public void onClickSwitchAction(View v) { Drawable drwStart = getResources().getDrawable(R.drawable.play); Drawable drwStop = getResources().getDrawable(R.drawable.stop); LinearLayout lllFrag = (LinearLayout) v.getParent(); LinearLayout llTimePicker = (LinearLayout) lllFrag.findViewById(R.id.llTimePicker); LinearLayout llStatus = (LinearLayout) lllFrag.findViewById(R.id.llStatus); TextView tvRecording = (TextView) llStatus.findViewById(R.id.tvRecording); ImageView ivRecording = (ImageView) llStatus.findViewById(R.id.ivRecording); Animation anim = new AlphaAnimation(0.0f, 1.0f); Log.d(CLASSNAME, "BEFORE: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); ImageView iv = (ImageView) v; int currentStatus = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).getStatus(); if (currentStatus == ActivitySession.STATUS_STOPPED) { Log.d(CLASSNAME, "Status is STOPPED. Shift to STARTED"); iv.setImageDrawable(drwStop); llTimePicker.setVisibility(View.INVISIBLE); anim.setDuration(500); anim.setStartOffset(20); anim.setRepeatMode(Animation.REVERSE); anim.setRepeatCount(Animation.INFINITE); Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckIn(); } else { Log.d(CLASSNAME, "Status is STARTED. Shift to STOPPED"); iv.setImageDrawable(drwStart); llTimePicker.setVisibility(View.VISIBLE); anim.setRepeatCount(0); ActivitySession as = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()); String sSubjectId = as.getId_subject(); double dLat = as.getLocation_latitude(); double dLong = as.getLocation_longitude(); long lCheckOut = new Date().getTime(); long lCheckIn = Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).doCheckOut(); // Save data into both databases DateUtils du = new DateUtils(); Log.i(CLASSNAME, "Recording activity into both databasees:" + as.getId_subject() + " / " + du.duration(lCheckIn, lCheckOut)); // TODO make some control here to make this transactional // Save in backend recordActivityBackend(sSubjectId, lCheckIn, lCheckOut, dLat, dLong, ActivityDO.ACTIVITY_RECORD_MODE_SYNCHRONOUS); // Save in local database recordActivitySQLite(sSubjectId, lCheckIn, lCheckOut, dLat, dLong); TextView tvDuration = (TextView) lllFrag.findViewById(R.id.tvDuration); tvDuration.setText( du.duration(Session.getSingleInstance().getDatabaseHandler().getAccumulatedTime(sSubjectId))); Toast.makeText(getApplicationContext(), "Recorded " + du.duration(lCheckIn, lCheckOut), Toast.LENGTH_SHORT).show(); // // Update history layout // LayoutInflater inflater = LayoutInflater.from(this); LinearLayout llParent = (LinearLayout) inflater.inflate(R.layout.check_item, null); LinearLayout liContent = (LinearLayout) llParent.getChildAt(0); // ImageView ivParent = (ImageView) liContent.findViewById(R.id.imageViewStart); // ivParent.setImageResource(R.drawable.rec_50x); //TextView tvTimeStamp = (TextView) liContent.getChildAt(1); TextView tvTimeStamp = (TextView) liContent.findViewById(R.id.textViewTimeStamp); tvTimeStamp.setText(Constants.TIME_FORMAT.format(lCheckIn)); tvTimeStamp.setTag(Long.valueOf(lCheckIn)); TextView tvDurRecord = (TextView) liContent.findViewById(R.id.textViewDuration); tvDurRecord.setText(" [" + du.duration(lCheckIn, lCheckOut) + "]"); // Passing subject id as parameter tvDurRecord.setTag(sSubjectId); LinearLayout llHistory = (LinearLayout) lllFrag.findViewById(R.id.llHistory); // Set index number so that the record can be removed int iTag = (llHistory.getChildCount() - 1) / 2; llParent.setTag(iTag); llHistory.addView(inflater.inflate(R.layout.tag_divider, llHistory, false), 1); llHistory.addView(llParent, 2); } tvRecording.startAnimation(anim); ivRecording.startAnimation(anim); Log.d(CLASSNAME, "AFTER: " + Session.getSingleInstance().getActivity(mViewPager.getCurrentItem()).toString()); }
From source file:com.gh4a.IssueLabelListActivity.java
private void selectLabel(TextView tvLabel, View viewColor, String color, boolean clearOtherSelected, EditText etLabel) {/*w w w. j a v a 2s . co m*/ final Typeface boldCondensed = getApplicationContext().boldCondensed; tvLabel.setTag(color); viewColor.setBackgroundColor(Color.parseColor("#" + color)); tvLabel.setBackgroundColor(Color.parseColor("#" + color)); int r = Color.red(Color.parseColor("#" + color)); int g = Color.green(Color.parseColor("#" + color)); int b = Color.blue(Color.parseColor("#" + color)); if (r + g + b < 383) { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_dark)); } else { tvLabel.setTextColor(getResources().getColor(R.color.abs__primary_text_holo_light)); } tvLabel.setTypeface(boldCondensed); mSelectedColor = color; mSelectedEtLabel = etLabel; mSelectedLabel = tvLabel.getText().toString(); if (clearOtherSelected) { clearOtherSelected(false); } }
From source file:com.yojiokisoft.yumekanow.activity.MakeCardActivity.java
/** * ????./*from w w w . j a va 2 s . c om*/ * * @param textView * @param backColor */ private void setBackAndForeColorLabel(TextView textView, int backColor) { int foreColor = backColor ^ 0xffffff; textView.setTextColor(foreColor); textView.setBackgroundColor(backColor); textView.setTag(backColor); String hex = String.format("%06x", backColor & 0x00ffffff); textView.setText("#" + hex); }