List of usage examples for android.widget TextView setTag
public void setTag(final Object tag)
From source file:us.bridgeses.slidedatetimepicker.SlidingTabLayout.java
private void populateTabStrip() { final PagerAdapter adapter = mViewPager.getAdapter(); final View.OnClickListener tabClickListener = new TabClickListener(); for (int i = 0; i < adapter.getCount(); i++) { View tabView = null;//from www . ja va 2s . c o m TextView tabTitleView = null; if (mTabViewLayoutId != 0) { // If there is a custom tab view layout id set, try and inflate it tabView = LayoutInflater.from(getContext()).inflate(mTabViewLayoutId, mTabStrip, false); tabTitleView = (TextView) tabView.findViewById(mTabViewTextViewId); } if (tabView == null) { tabView = createDefaultTabView(getContext()); } if (tabTitleView == null && TextView.class.isInstance(tabView)) { tabTitleView = (TextView) tabView; } tabTitleView.setText(adapter.getPageTitle(i)); tabView.setOnClickListener(tabClickListener); // Used to get a reference to each tab's TextView in order to // update the text in setTabText(). mTabTitleViews.put(i, tabTitleView); tabTitleView.setTag(i); mTabStrip.addView(tabView); } }
From source file:org.telegram.ui.ActionBar.ActionBarMenuItem.java
public TextView addSubItem(int id, String text, int icon) { if (popupLayout == null) { rect = new Rect(); location = new int[2]; popupLayout = new ActionBarPopupWindow.ActionBarPopupWindowLayout(getContext()); popupLayout.setOnTouchListener(new OnTouchListener() { @Override/*w ww . j av a2 s. c o m*/ public boolean onTouch(View v, MotionEvent event) { if (event.getActionMasked() == MotionEvent.ACTION_DOWN) { if (popupWindow != null && popupWindow.isShowing()) { v.getHitRect(rect); if (!rect.contains((int) event.getX(), (int) event.getY())) { popupWindow.dismiss(); } } } return false; } }); popupLayout.setDispatchKeyEventListener(new ActionBarPopupWindow.OnDispatchKeyEventListener() { @Override public void onDispatchKeyEvent(KeyEvent keyEvent) { if (keyEvent.getKeyCode() == KeyEvent.KEYCODE_BACK && keyEvent.getRepeatCount() == 0 && popupWindow != null && popupWindow.isShowing()) { popupWindow.dismiss(); } } }); } TextView textView = new TextView(getContext()); textView.setTextColor(ContextCompat.getColor(getContext(), R.color.primary_text)); textView.setBackgroundResource(R.drawable.list_selector); if (!LocaleController.isRTL) { textView.setGravity(Gravity.CENTER_VERTICAL); } else { textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT); } textView.setPadding(AndroidUtilities.dp(16), 0, AndroidUtilities.dp(16), 0); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18); textView.setMinWidth(AndroidUtilities.dp(196)); textView.setTag(id); textView.setText(text); if (icon != 0) { textView.setCompoundDrawablePadding(AndroidUtilities.dp(12)); if (!LocaleController.isRTL) { textView.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(icon), null, null, null); } else { textView.setCompoundDrawablesWithIntrinsicBounds(null, null, getResources().getDrawable(icon), null); } } popupLayout.setShowedFromBotton(showFromBottom); popupLayout.addView(textView); LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) textView.getLayoutParams(); if (LocaleController.isRTL) { layoutParams.gravity = Gravity.RIGHT; } layoutParams.width = LayoutHelper.MATCH_PARENT; layoutParams.height = AndroidUtilities.dp(48); textView.setLayoutParams(layoutParams); textView.setOnClickListener(new OnClickListener() { @Override public void onClick(View view) { if (popupWindow != null && popupWindow.isShowing()) { if (processedPopupClick) { return; } processedPopupClick = true; popupWindow.dismiss(allowCloseAnimation); } if (parentMenu != null) { parentMenu.onItemClick((Integer) view.getTag()); } else if (delegate != null) { delegate.onItemClick((Integer) view.getTag()); } } }); menuHeight += layoutParams.height; return textView; }
From source file:ch.teamuit.android.soundplusplus.LibraryActivity.java
/** * Create or recreate the limiter breadcrumbs. *//*from w w w . java 2s. co m*/ public void updateLimiterViews() { mLimiterViews.removeAllViews(); Limiter limiterData = mPagerAdapter.getCurrentLimiter(); if (limiterData != null) { String[] limiter = limiterData.names; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; for (int i = 0; i != limiter.length; ++i) { PaintDrawable background = new PaintDrawable(Color.GRAY); background.setCornerRadius(5); TextView view = new TextView(this); view.setSingleLine(); view.setEllipsize(TextUtils.TruncateAt.MARQUEE); view.setText(limiter[i] + " | X"); view.setTextColor(Color.WHITE); view.setBackgroundDrawable(background); view.setLayoutParams(params); view.setPadding(5, 2, 5, 2); view.setTag(i); view.setOnClickListener(this); mLimiterViews.addView(view); } mLimiterScroller.setVisibility(View.VISIBLE); } else { mLimiterScroller.setVisibility(View.GONE); } }
From source file:com.cssweb.android.base.DialogActivity.java
protected void initStockBar() { hiddenOrDisplayStockBar(View.VISIBLE); TextView stkBar1 = (TextView) findViewById(R.id.njzq_userstockbtn1); TextView stkBar2 = (TextView) findViewById(R.id.njzq_userstockbtn2); TextView stkBar3 = (TextView) findViewById(R.id.njzq_userstockbtn3); TextView stkBar4 = (TextView) findViewById(R.id.njzq_userstockbtn4); TextView stkBar5 = (TextView) findViewById(R.id.njzq_userstockbtn5); TextView stkBar6 = (TextView) findViewById(R.id.njzq_userstockbtn6); stkBar1.setTextColor(getResources().getColor(R.color.zr_white)); stkBar1.setOnClickListener(toolbarClick); stkBar1.setVisibility(View.VISIBLE); stkBar1.setTag(11); stkBar2.setTextColor(getResources().getColor(R.color.zr_white)); stkBar2.setOnClickListener(toolbarClick); stkBar2.setVisibility(View.VISIBLE); stkBar2.setTag(12);/*from w w w. j a va 2s . c o m*/ stkBar3.setTextColor(getResources().getColor(R.color.zr_white)); stkBar3.setOnClickListener(toolbarClick); stkBar3.setVisibility(View.VISIBLE); stkBar3.setTag(13); stkBar4.setTextColor(getResources().getColor(R.color.zr_white)); stkBar4.setOnClickListener(toolbarClick); stkBar4.setVisibility(View.VISIBLE); stkBar4.setTag(14); stkBar5.setTextColor(getResources().getColor(R.color.zr_white)); stkBar5.setOnClickListener(toolbarClick); stkBar5.setVisibility(View.VISIBLE); stkBar5.setTag(15); stkBar6.setTextColor(getResources().getColor(R.color.zr_white)); stkBar6.setOnClickListener(toolbarClick); stkBar6.setVisibility(View.VISIBLE); stkBar6.setTag(16); }
From source file:ch.blinkenlights.android.vanilla.LibraryActivity.java
/** * Create or recreate the limiter breadcrumbs. */// w ww . j a v a 2s. c o m public void updateLimiterViews() { mLimiterViews.removeAllViews(); Limiter limiterData = mPagerAdapter.getCurrentLimiter(); if (limiterData != null) { String[] limiter = limiterData.names; LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT); params.leftMargin = 5; for (int i = 0; i != limiter.length; ++i) { int color = (i + 1 == limiter.length ? 0xFFA0A0A0 : 0xFFC0C0C0); PaintDrawable background = new PaintDrawable(color); background.setCornerRadius(0); TextView view = new TextView(this); view.setSingleLine(); view.setEllipsize(TextUtils.TruncateAt.MARQUEE); view.setText(limiter[i]); view.setTextColor(Color.WHITE); view.setBackgroundDrawable(background); view.setLayoutParams(params); view.setPadding(14, 6, 14, 6); view.setTag(i); view.setOnClickListener(this); mLimiterViews.addView(view); } mLimiterScroller.setVisibility(View.VISIBLE); } else { mLimiterScroller.setVisibility(View.GONE); } }
From source file:com.github.mobile.util.HttpImageGetter.java
/** * Bind text view to HTML string/*from w w w . j av a 2 s . c o m*/ * * @param view * @param html * @param id * @return this image getter */ public HttpImageGetter bind(final TextView view, final String html, final Object id) { unbindViewFromGifs(view); if (TextUtils.isEmpty(html)) return hide(view, id); CharSequence encoded = fullHtmlCache.get(id); if (encoded != null) { addViewToGifCb(view, id); return show(view, encoded, id); } encoded = rawHtmlCache.get(id); if (encoded == null) { encoded = HtmlUtils.encode(html, loading); if (containsImages(html)) rawHtmlCache.put(id, encoded); else { rawHtmlCache.remove(id); fullHtmlCache.put(id, encoded); return show(view, encoded, id); } } if (TextUtils.isEmpty(encoded)) return hide(view, id); show(view, encoded, id); view.setTag(id); ImageGetterAsyncTask asyncTask = new ImageGetterAsyncTask(); AsyncTaskCompat.executeParallel(asyncTask, html, id, view); return this; }
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/*from w w w . j ava 2 s .co m*/ 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)); }// w w w . j av a 2 s .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:es.usc.citius.servando.calendula.fragments.ScheduleTimetableFragment.java
private void setupScheduleEntrySpinners(final View entryView, ScheduleItem scheduleItem, String[] routineNames) {// w ww. jav a 2s . co 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); } }); // set up the dose selection adapter // ArrayAdapter<String> doseAdapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, doses); // doseAdapter.setDropDownViewResource(R.layout.spinner_dropdown_item); // doseSpinner.setAdapter(doseAdapter); // select 1 pill by default // doseSpinner.setSelection((int) scheduleItem.dose() - 1); // dose "1" is located at the index "0", and so on 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.ubergeek42.WeechatAndroid.adapters.ChatLinesAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { View retview; // The view to return TextView textview; boolean mustDrawReadMarker = getItemId(position) == buffer.readMarkerLine; // we only want to reuse TextViews, not the special lastLineRead view, // so force view recreation if (mustDrawReadMarker || convertView instanceof RelativeLayout) convertView = null;/* ww w . ja v a 2 s .c o m*/ if (convertView == null) { if (mustDrawReadMarker) { retview = inflater.inflate(R.layout.chatview_line_read_marker, null); textview = (TextView) retview.findViewById(R.id.chatline_message); //noinspection deprecation retview.findViewById(R.id.separator).setBackgroundDrawable( new ColorDrawable(0xFF000000 | ColorScheme.get().chat_read_marker[0])); } else { textview = (TextView) inflater.inflate(R.layout.chatview_line, null); retview = textview; } textview.setTextColor(0xFF000000 | ColorScheme.get().defaul[0]); textview.setMovementMethod(LinkMovementMethod.getInstance()); } else { // convertview is only ever not null for the simple case textview = (TextView) convertView; retview = textview; } textview.setTextSize(P.textSize); Line line = (Line) getItem(position); textview.setText(line.spannable); textview.setTag(line); if (typeface != null) textview.setTypeface(typeface); return retview; }