List of usage examples for android.widget TextView getTag
@ViewDebug.ExportedProperty
public Object getTag()
From source file:com.androzic.waypoint.WaypointDetails.java
@SuppressLint("NewApi") private void updateWaypointDetails(double lat, double lon) { Androzic application = Androzic.getApplication(); AppCompatActivity activity = (AppCompatActivity) getActivity(); activity.getSupportActionBar().setTitle(waypoint.name); View view = getView();//from w ww.java2 s . c o m final TextView coordsView = (TextView) view.findViewById(R.id.coordinates); coordsView.requestFocus(); coordsView.setTag(Integer.valueOf(StringFormatter.coordinateFormat)); coordsView.setText(StringFormatter.coordinates(" ", waypoint.latitude, waypoint.longitude)); coordsView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { int format = ((Integer) coordsView.getTag()).intValue() + 1; if (format == 5) format = 0; coordsView.setText(StringFormatter.coordinates(format, " ", waypoint.latitude, waypoint.longitude)); coordsView.setTag(Integer.valueOf(format)); } }); if (waypoint.altitude != Integer.MIN_VALUE) { ((TextView) view.findViewById(R.id.altitude)) .setText("\u2336 " + StringFormatter.elevationH(waypoint.altitude)); view.findViewById(R.id.altitude).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.altitude).setVisibility(View.GONE); } if (waypoint.proximity > 0) { ((TextView) view.findViewById(R.id.proximity)) .setText("~ " + StringFormatter.distanceH(waypoint.proximity)); view.findViewById(R.id.proximity).setVisibility(View.VISIBLE); } else { view.findViewById(R.id.proximity).setVisibility(View.GONE); } double dist = Geo.distance(lat, lon, waypoint.latitude, waypoint.longitude); double bearing = Geo.bearing(lat, lon, waypoint.latitude, waypoint.longitude); bearing = application.fixDeclination(bearing); String distance = StringFormatter.distanceH(dist) + " " + StringFormatter.angleH(bearing); ((TextView) view.findViewById(R.id.distance)).setText(distance); ((TextView) view.findViewById(R.id.waypointset)).setText(waypoint.set.name); if (waypoint.date != null) { view.findViewById(R.id.date_row).setVisibility(View.VISIBLE); ((TextView) view.findViewById(R.id.date)) .setText(DateFormat.getDateFormat(activity).format(waypoint.date) + " " + DateFormat.getTimeFormat(activity).format(waypoint.date)); } else { view.findViewById(R.id.date_row).setVisibility(View.GONE); } if ("".equals(waypoint.description)) { view.findViewById(R.id.description_row).setVisibility(View.GONE); } else { WebView description = (WebView) view.findViewById(R.id.description); String descriptionHtml; try { TypedValue tv = new TypedValue(); Theme theme = activity.getTheme(); Resources resources = getResources(); theme.resolveAttribute(android.R.attr.textColorPrimary, tv, true); int secondaryColor = resources.getColor(tv.resourceId); String css = String.format( "<style type=\"text/css\">html,body{margin:0;background:transparent} *{color:#%06X}</style>\n", (secondaryColor & 0x00FFFFFF)); descriptionHtml = css + waypoint.description; description.setWebViewClient(new WebViewClient() { @SuppressLint("NewApi") @Override public void onPageFinished(WebView view, String url) { view.setBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) view.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); } }); description.setBackgroundColor(Color.TRANSPARENT); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) description.setLayerType(WebView.LAYER_TYPE_SOFTWARE, null); } catch (Resources.NotFoundException e) { description.setBackgroundColor(Color.LTGRAY); descriptionHtml = waypoint.description; } WebSettings settings = description.getSettings(); settings.setDefaultTextEncodingName("utf-8"); settings.setAllowFileAccess(true); Uri baseUrl = Uri.fromFile(new File(application.dataPath)); description.loadDataWithBaseURL(baseUrl.toString() + "/", descriptionHtml, "text/html", "utf-8", null); view.findViewById(R.id.description_row).setVisibility(View.VISIBLE); } }
From source file:opensourceproject.kanjisteps.Practice_slides.java
public void btnAnswer(View view) { /*//from w ww . j ava 2 s . c o m String userAnswer; String kanjiDisplayed; String correctAnswer; TextView textView = (TextView)findViewById(R.id.textToDisplay); Button button = (Button)view; userAnswer = button.getText().toString(); kanjiDisplayed = textView.getText().toString(); KanjiToStudyAdapter dbAdapter = new KanjiToStudyAdapter(this); correctAnswer = dbAdapter.getOnyomiByKanji(kanjiDisplayed); */ String kanjiDisplayed; TextView textView = (TextView) findViewById(R.id.textToDisplay); kanjiDisplayed = textView.getText().toString(); if (kanjiDisplayed.equals("You don't have any items to review yet! Check back later.")) return; String userAnswer; String quizTag; //1 means ENGLISH MEANING, 2 means JAPANESE READING Button button = (Button) view; userAnswer = button.getTag().toString(); quizTag = textView.getTag().toString(); disableButtons(); new asyncCaller().execute(userAnswer, correctAnswer, kanjiDisplayed, quizTag); //quizByLevel(); }
From source file:org.dalol.orthodoxmezmurmedia.utilities.widgets.AmharicKeyboardView.java
private void processKeyInput(TextView textView) { if (mEditText != null) { if (!mEditText.isFocused()) mEditText.requestFocus();/* w ww . j ava 2 s . c o m*/ Editable editableText = mEditText.getText(); int start = mEditText.getSelectionStart(); if (start == -1) return; editableText.insert(start, textView.getText()); KeyboardKey tag = (KeyboardKey) textView.getTag(); List<String> modifierList = tag.getKeyModifiers(); handleModifiers(modifierList); } }
From source file:com.nadmm.airports.afd.AirportDetailsFragment.java
protected void showWxInfo(Metar metar) { if (metar.stationId == null) { return;/* w w w .j av a 2s . co m*/ } if (metar.isValid && mIcaoCode != null && mIcaoCode.equals(metar.stationId) && WxUtils.isWindAvailable(metar)) { showRunwayWindInfo(metar); } for (TextView tv : mAwosViews) { String icaoCode = (String) tv.getTag(); if (icaoCode.equals(metar.stationId)) { WxUtils.setColorizedWxDrawable(tv, metar, mDeclination); break; } } }
From source file:com.nadmm.airports.afd.AirportDetailsFragment.java
protected void requestMetars(String action, boolean force, boolean cacheOnly) { if (mAwosViews.size() == 0) { return;/*from w w w.j a v a 2 s .c o m*/ } ArrayList<String> stationIds = new ArrayList<>(); for (TextView tv : mAwosViews) { String stationId = (String) tv.getTag(); stationIds.add(stationId); } Intent service = new Intent(getActivity(), MetarService.class); service.setAction(action); service.putExtra(NoaaService.STATION_IDS, stationIds); service.putExtra(NoaaService.TYPE, NoaaService.TYPE_TEXT); if (force) { service.putExtra(NoaaService.FORCE_REFRESH, true); } else if (cacheOnly) { service.putExtra(NoaaService.CACHE_ONLY, true); } getActivity().startService(service); }
From source file:com.nadmm.airports.afd.AirportDetailsFragment.java
protected void showRunwayWindInfo(Metar metar) { for (TextView tv : mRunwayViews) { Bundle tag = (Bundle) tv.getTag(); String id = tag.getString(Runways.BASE_END_ID); long rwyHeading = tag.getInt(Runways.BASE_END_HEADING); long windDir = GeoUtils.applyDeclination(metar.windDirDegrees, mDeclination); long headWind = WxUtils.getHeadWindComponent(metar.windSpeedKnots, windDir, rwyHeading); if (headWind < 0) { // If this is a tail wind, use the other end id = tag.getString(Runways.RECIPROCAL_END_ID); rwyHeading = (rwyHeading + 180) % 360; }/* www .j a v a2 s. com*/ long crossWind = WxUtils.getCrossWindComponent(metar.windSpeedKnots, windDir, rwyHeading); String side = (crossWind >= 0) ? "right" : "left"; crossWind = Math.abs(crossWind); StringBuilder windInfo = new StringBuilder(); if (crossWind > 0) { windInfo.append(String.format(Locale.US, "%d %s %s x-wind", crossWind, crossWind > 1 ? "knots" : "knot", side)); } else { windInfo.append("no x-wind"); } if (metar.windGustKnots < Integer.MAX_VALUE) { double gustFactor = (metar.windGustKnots - metar.windSpeedKnots) / 2; windInfo.append(String.format(Locale.US, ", %d knots gust factor", Math.round(gustFactor))); } tv.setText(String.format(Locale.US, "Rwy %s: %s", id, windInfo.toString())); tv.setVisibility(View.VISIBLE); } }
From source file:com.master.metehan.filtereagle.AdapterAccess.java
@Override public void bindView(final View view, final Context context, final Cursor cursor) { // Get values final long id = cursor.getLong(colID); final int version = cursor.getInt(colVersion); final int protocol = cursor.getInt(colProtocol); final String daddr = cursor.getString(colDaddr); final int dport = cursor.getInt(colDPort); long time = cursor.getLong(colTime); int allowed = cursor.getInt(colAllowed); int block = cursor.getInt(colBlock); long sent = cursor.isNull(colSent) ? -1 : cursor.getLong(colSent); long received = cursor.isNull(colReceived) ? -1 : cursor.getLong(colReceived); int connections = cursor.isNull(colConnections) ? -1 : cursor.getInt(colConnections); // Get views/*ww w . ja v a 2 s. c om*/ TextView tvTime = (TextView) view.findViewById(R.id.tvTime); ImageView ivBlock = (ImageView) view.findViewById(R.id.ivBlock); final TextView tvDest = (TextView) view.findViewById(R.id.tvDest); LinearLayout llTraffic = (LinearLayout) view.findViewById(R.id.llTraffic); TextView tvConnections = (TextView) view.findViewById(R.id.tvConnections); TextView tvTraffic = (TextView) view.findViewById(R.id.tvTraffic); // Set values tvTime.setText(new SimpleDateFormat("dd HH:mm").format(time)); if (block < 0) ivBlock.setImageDrawable(null); else { ivBlock.setImageResource(block > 0 ? R.drawable.host_blocked : R.drawable.host_allowed); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { Drawable wrap = DrawableCompat.wrap(ivBlock.getDrawable()); DrawableCompat.setTint(wrap, block > 0 ? colorOff : colorOn); } } tvDest.setText( Util.getProtocolName(protocol, version, true) + " " + daddr + (dport > 0 ? "/" + dport : "")); if (Util.isNumericAddress(daddr) && tvDest.getTag() == null) new AsyncTask<String, Object, String>() { @Override protected void onPreExecute() { tvDest.setTag(id); } @Override protected String doInBackground(String... args) { try { return InetAddress.getByName(args[0]).getHostName(); } catch (UnknownHostException ignored) { return args[0]; } } @Override protected void onPostExecute(String addr) { Object tag = tvDest.getTag(); if (tag != null && (Long) tag == id) tvDest.setText(Util.getProtocolName(protocol, version, true) + " >" + addr + (dport > 0 ? "/" + dport : "")); tvDest.setTag(null); } }.execute(daddr); if (allowed < 0) tvDest.setTextColor(colorText); else if (allowed > 0) tvDest.setTextColor(colorOn); else tvDest.setTextColor(colorOff); llTraffic.setVisibility(connections > 0 || sent > 0 || received > 0 ? View.VISIBLE : View.GONE); if (connections > 0) tvConnections.setText(context.getString(R.string.msg_count, connections)); if (sent > 1024 * 1204 * 1024L || received > 1024 * 1024 * 1024L) tvTraffic.setText(context.getString(R.string.msg_gb, (sent > 0 ? sent / (1024 * 1024 * 1024f) : 0), (received > 0 ? received / (1024 * 1024 * 1024f) : 0))); else if (sent > 1204 * 1024L || received > 1024 * 1024L) tvTraffic.setText(context.getString(R.string.msg_mb, (sent > 0 ? sent / (1024 * 1024f) : 0), (received > 0 ? received / (1024 * 1024f) : 0))); else tvTraffic.setText(context.getString(R.string.msg_kb, (sent > 0 ? sent / 1024f : 0), (received > 0 ? received / 1024f : 0))); }
From source file:hu.fnf.devel.atlas.Atlas.java
public void saveCategory(View v) { TextView seltext = (TextView) v.getRootView().findViewById(R.id.selectedParent); Builder builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_CATEGORIES); builder.appendPath("cat"); if (seltext.getTag() == null) { seltext.setTag(String.valueOf(AtlasData.OUTCOME)); }//from ww w . java2s . c om builder.appendPath((String) seltext.getTag()); Cursor parent = getContentResolver().query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null); if (parent != null && parent.moveToFirst()) { builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_CATEGORIES); builder.appendPath("childs"); builder.appendPath((String) seltext.getTag()); Cursor kids = getContentResolver().query(builder.build(), AtlasData.CATEGORIES_COLUMNS, null, null, null); String parentid = (String) seltext.getTag(); String name = (String) ((TextView) v.getRootView().findViewById(R.id.chooseparentfor)).getText(); String amount = (String) ((TextView) v.getRootView().findViewById(R.id.defaultAmount)).getText() .toString(); int id = Integer.valueOf(parentid) * (AtlasData.MAX_CAT_WIDTH + 1) + kids.getCount() + 1; int depth = parent.getInt(AtlasData.CATEGORIES_DEPTH) - 1; Category newcat = new Category(String.valueOf(id), name, amount, String.valueOf(depth), AtlasData.getColor(parent), AtlasData.getColor(parent), AtlasData.getColor(parent)); AtlasParseSMSTask.insert(newcat); builder = new Builder(); builder.scheme("content"); builder.authority(AtlasData.DB_AUTHORITY); builder.appendPath(AtlasData.TABLE_CATEGORIES); builder.appendPath("parent"); builder.appendPath((String) parentid); getContentResolver().update(builder.build(), null, null, null); } parent.close(); changeViewLevel(R.layout.category_view, AtlasData.peekPos().page); }
From source file:com.www.avtovokzal.org.MainActivity.java
private void listViewListener() { listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override/* ww w .jav a 2s .c o m*/ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { String name; String numberToView; RelativeLayout rl = (RelativeLayout) view; TextView textViewTime = (TextView) rl.getChildAt(0); TextView textViewNumber = (TextView) rl.getChildAt(1); TextView textViewName = (TextView) rl.getChildAt(2); time = textViewTime.getText().toString(); number = textViewNumber.getTag().toString(); numberToView = textViewNumber.getText().toString(); name = textViewName.getText().toString(); Intent intent = new Intent(getApplicationContext(), InfoActivity.class); intent.putExtra("number", number); intent.putExtra("numberToView", numberToView); intent.putExtra("time", time); intent.putExtra("name", name); intent.putExtra("day", day); startActivity(intent); } }); listView.setOnScrollListener(new AbsListView.OnScrollListener() { @Override public void onScrollStateChanged(AbsListView view, int scrollState) { } @Override public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) { int def = totalItemCount - (firstVisibleItem + visibleItemCount); if (totalItemCount > 0 && def < 3 && fab.getVisibility() == View.VISIBLE) { Animation fadeOutAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_out); fab.setAnimation(fadeOutAnimation); fab.setVisibility(View.GONE); } else if (totalItemCount > 0 && def > 3 && fab.getVisibility() != View.VISIBLE) { Animation fadeInAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.fade_in); fab.setAnimation(fadeInAnimation); fab.setVisibility(View.VISIBLE); } } }); }
From source file:com.android.inputmethod.latin.suggestions.SuggestionStripLayoutHelper.java
/** * Layout suggestions to the suggestions strip. And returns the start index of more * suggestions.//from w w w .j a v a 2 s . co m * * @param suggestedWords suggestions to be shown in the suggestions strip. * @param stripView the suggestions strip view. * @param placerView the view where the debug info will be placed. * @return the start index of more suggestions. */ public int layoutAndReturnStartIndexOfMoreSuggestions(final SuggestedWords suggestedWords, final ViewGroup stripView, final ViewGroup placerView) { if (suggestedWords.isPunctuationSuggestions()) { return layoutPunctuationsAndReturnStartIndexOfMoreSuggestions((PunctuationSuggestions) suggestedWords, stripView); } final int startIndexOfMoreSuggestions = setupWordViewsAndReturnStartIndexOfMoreSuggestions(suggestedWords, mSuggestionsCountInStrip); final TextView centerWordView = mWordViews.get(mCenterPositionInStrip); final int stripWidth = stripView.getWidth(); final int centerWidth = getSuggestionWidth(mCenterPositionInStrip, stripWidth); if (suggestedWords.size() == 1 || getTextScaleX(centerWordView.getText(), centerWidth, centerWordView.getPaint()) < MIN_TEXT_XSCALE) { // Layout only the most relevant suggested word at the center of the suggestion strip // by consolidating all slots in the strip. final int countInStrip = 1; mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip); layoutWord(mCenterPositionInStrip, stripWidth - mPadding); stripView.addView(centerWordView); setLayoutWeight(centerWordView, 1.0f, ViewGroup.LayoutParams.MATCH_PARENT); if (SuggestionStripView.DBG) { layoutDebugInfo(mCenterPositionInStrip, placerView, stripWidth); } final Integer lastIndex = (Integer) centerWordView.getTag(); return (lastIndex == null ? 0 : lastIndex) + 1; } final int countInStrip = mSuggestionsCountInStrip; mMoreSuggestionsAvailable = (suggestedWords.size() > countInStrip); int x = 0; for (int positionInStrip = 0; positionInStrip < countInStrip; positionInStrip++) { if (positionInStrip != 0) { final View divider = mDividerViews.get(positionInStrip); // Add divider if this isn't the left most suggestion in suggestions strip. addDivider(stripView, divider); x += divider.getMeasuredWidth(); } final int width = getSuggestionWidth(positionInStrip, stripWidth); final TextView wordView = layoutWord(positionInStrip, width); stripView.addView(wordView); setLayoutWeight(wordView, getSuggestionWeight(positionInStrip), ViewGroup.LayoutParams.MATCH_PARENT); x += wordView.getMeasuredWidth(); if (SuggestionStripView.DBG) { layoutDebugInfo(positionInStrip, placerView, x); } } return startIndexOfMoreSuggestions; }