List of usage examples for android.widget TextView getContext
@ViewDebug.CapturedViewProperty public final Context getContext()
From source file:net.alchemiestick.katana.winehqappdb.filter_dialog.java
public filter_dialog(Context cx, List<NameValuePair> data) { super(cx);// ww w. j av a 2 s .c o m this.cx = cx; this.webData = data; this.requestWindowFeature(Window.FEATURE_NO_TITLE); vocl = new View.OnClickListener() { public void onClick(View v) { onCheckboxClick(v); } }; maxLines = new OnEditorActionListener() { @Override public boolean onEditorAction(TextView tv, int action, KeyEvent key) { boolean handled = false; if (action == EditorInfo.IME_ACTION_DONE) { setMaxLines(tv.getText().toString()); tv.setText(getNamedData("iPage")); InputMethodManager imm = (InputMethodManager) tv.getContext() .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(tv.getWindowToken(), 0); handled = true; } return handled; } }; rateListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { rateSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; licenseListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { licenseSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; placementListener = new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { placementSelected((String) parent.getItemAtPosition(pos)); } public void onNothingSelected(AdapterView<?> parent) { } }; }
From source file:arun.com.chromer.browsing.article.util.ArticleUtil.java
/** * Changes the text selection handle colors. *///from w ww .ja v a2s .c o m public static void changeTextSelectionHandleColors(TextView textView, int color) { textView.setHighlightColor(Color.argb(40, Color.red(color), Color.green(color), Color.blue(color))); try { Field editorField = TextView.class.getDeclaredField("mEditor"); if (!editorField.isAccessible()) { editorField.setAccessible(true); } Object editor = editorField.get(textView); Class<?> editorClass = editor.getClass(); String[] handleNames = { "mSelectHandleLeft", "mSelectHandleRight", "mSelectHandleCenter" }; String[] resNames = { "mTextSelectHandleLeftRes", "mTextSelectHandleRightRes", "mTextSelectHandleRes" }; for (int i = 0; i < handleNames.length; i++) { Field handleField = editorClass.getDeclaredField(handleNames[i]); if (!handleField.isAccessible()) { handleField.setAccessible(true); } Drawable handleDrawable = (Drawable) handleField.get(editor); if (handleDrawable == null) { Field resField = TextView.class.getDeclaredField(resNames[i]); if (!resField.isAccessible()) { resField.setAccessible(true); } int resId = resField.getInt(textView); handleDrawable = ContextCompat.getDrawable(textView.getContext(), resId); } if (handleDrawable != null) { Drawable drawable = handleDrawable.mutate(); drawable.setColorFilter(color, PorterDuff.Mode.SRC_IN); handleField.set(editor, drawable); } } } catch (Exception ignored) { } }
From source file:com.silentcircle.silenttext.activity.AccountCreationActivity.java
@Override public void onError(final CharSequence message) { runOnUiThread(new Runnable() { @Override/*from w w w . ja v a2 s . c om*/ public void run() { TextView error = (TextView) findViewById(R.id.error); error.setText( message == null || message.length() <= 0 ? getString(R.string.error_unknown) : message); error.setVisibility(View.VISIBLE); error.startAnimation(AnimationUtils.loadAnimation(error.getContext(), R.anim.slide_down)); handler.removeCallbacks(hideError); handler.postDelayed(hideError, 5000); } }); }
From source file:com.gh4a.fragment.RepositoryFragment.java
private void fillData() { TextView tvRepoName = (TextView) mContentView.findViewById(R.id.tv_repo_name); SpannableStringBuilder repoName = new SpannableStringBuilder(); repoName.append(mRepository.getOwner().getLogin()); repoName.append("/"); repoName.append(mRepository.getName()); repoName.setSpan(new IntentSpan(tvRepoName.getContext()) { @Override//from w ww . j a va 2 s .c om protected Intent getIntent() { return IntentUtils.getUserActivityIntent(getActivity(), mRepository.getOwner()); } }, 0, mRepository.getOwner().getLogin().length(), 0); tvRepoName.setText(repoName); tvRepoName.setMovementMethod(UiUtils.CHECKING_LINK_METHOD); TextView tvParentRepo = (TextView) mContentView.findViewById(R.id.tv_parent); if (mRepository.isFork() && mRepository.getParent() != null) { Repository parent = mRepository.getParent(); tvParentRepo.setVisibility(View.VISIBLE); tvParentRepo.setText( getString(R.string.forked_from, parent.getOwner().getLogin() + "/" + parent.getName())); tvParentRepo.setOnClickListener(this); tvParentRepo.setTag(parent); } else { tvParentRepo.setVisibility(View.GONE); } fillTextView(R.id.tv_desc, 0, mRepository.getDescription()); fillTextView(R.id.tv_language, R.string.repo_language, mRepository.getLanguage()); fillTextView(R.id.tv_url, 0, !StringUtils.isBlank(mRepository.getHomepage()) ? mRepository.getHomepage() : mRepository.getHtmlUrl()); mContentView.findViewById(R.id.cell_stargazers).setOnClickListener(this); mContentView.findViewById(R.id.cell_forks).setOnClickListener(this); mContentView.findViewById(R.id.cell_pull_requests).setOnClickListener(this); mContentView.findViewById(R.id.tv_contributors_label).setOnClickListener(this); mContentView.findViewById(R.id.other_info).setOnClickListener(this); mContentView.findViewById(R.id.tv_releases_label).setOnClickListener(this); Permissions permissions = mRepository.getPermissions(); updateClickableLabel(R.id.tv_collaborators_label, permissions != null && permissions.hasPushAccess()); updateClickableLabel(R.id.tv_downloads_label, mRepository.isHasDownloads()); updateClickableLabel(R.id.tv_wiki_label, mRepository.isHasWiki()); TextView tvStargazersCount = (TextView) mContentView.findViewById(R.id.tv_stargazers_count); tvStargazersCount.setText(String.valueOf(mRepository.getWatchers())); TextView tvForksCount = (TextView) mContentView.findViewById(R.id.tv_forks_count); tvForksCount.setText(String.valueOf(mRepository.getForks())); LinearLayout llIssues = (LinearLayout) mContentView.findViewById(R.id.cell_issues); if (mRepository.isHasIssues()) { llIssues.setVisibility(View.VISIBLE); llIssues.setOnClickListener(this); // value will be filled when PR count arrives } else { llIssues.setVisibility(View.GONE); } mContentView.findViewById(R.id.tv_private) .setVisibility(mRepository.isPrivate() ? View.VISIBLE : View.GONE); }
From source file:com.nadmm.airports.wx.MetarFragment.java
protected void showWindInfo(LinearLayout layout, Metar metar) { View row = addRow(layout, getWindsDescription(metar)); TextView tv = (TextView) row.findViewById(R.id.item_label); if (metar.windDirDegrees > 0) { float declination = GeoUtils.getMagneticDeclination(mLocation); Drawable wind = WxUtils.getWindBarbDrawable(tv.getContext(), metar, declination); tv.setCompoundDrawablesWithIntrinsicBounds(wind, null, null, null); tv.setCompoundDrawablePadding(UiUtils.convertDpToPx(getActivity(), 6)); }// ww w .j av a 2s . co m if (metar.windGustKnots < Integer.MAX_VALUE) { double gustFactor = metar.windGustKnots - metar.windSpeedKnots; addRow(layout, String.format("Add %d knots to your normal approach speed", Math.round(gustFactor / 2))); } if (metar.wshft) { StringBuilder sb = new StringBuilder(); sb.append("Wind shift of 45\u00B0 or more detected during past hour"); if (metar.fropa) { sb.append(" due to frontal passage"); } addRow(layout, sb.toString()); } }
From source file:com.github.antoniodisanto92.swipeselector.SwipeAdapter.java
@SuppressWarnings("deprecation") private void setTextAppearanceCompat(TextView textView, int appearanceRes) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { textView.setTextAppearance(appearanceRes); } else {//from ww w . j a va 2 s. c o m textView.setTextAppearance(textView.getContext(), appearanceRes); } }
From source file:com.granita.tasks.groupings.BaseTaskViewDescriptor.java
protected void setDueDate(TextView view, ImageView dueIcon, Time dueDate, boolean isClosed) { if (view != null && dueDate != null) { Time now = mNow;/*from w w w. j a v a2s . c o m*/ if (now == null) { now = mNow = new Time(); } if (!now.timezone.equals(TimeZone.getDefault().getID())) { now.clear(TimeZone.getDefault().getID()); } if (Math.abs(now.toMillis(false) - System.currentTimeMillis()) > 5000) { now.setToNow(); now.normalize(true); } dueDate.normalize(true); view.setText(new DateFormatter(view.getContext()).format(dueDate, now, DateFormatContext.LIST_VIEW)); if (dueIcon != null) { dueIcon.setVisibility(View.VISIBLE); } // highlight overdue dates & times, handle allDay tasks separately if ((!dueDate.allDay && dueDate.before(now) || dueDate.allDay && (dueDate.year < now.year || dueDate.yearDay <= now.yearDay && dueDate.year == now.year)) && !isClosed) { view.setTextAppearance(view.getContext(), R.style.task_list_overdue_text); } else { view.setTextAppearance(view.getContext(), R.style.task_list_due_text); } } else if (view != null) { view.setText(""); if (dueIcon != null) { dueIcon.setVisibility(View.GONE); } } }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static void styleText(final TextView tv, final HashMap<String, Object> d) { styleText(tv, getFontStyle(tv.getContext(), d)); }
From source file:com.fastbootmobile.encore.app.fragments.ListenNowFragment.java
private void setupHeader(ParallaxScrollListView listView) { LayoutInflater inflater = LayoutInflater.from(listView.getContext()); mHeaderView = inflater.inflate(R.layout.header_listen_now, listView, false); mCardSearchBox = (CardView) mHeaderView.findViewById(R.id.cardSearchBox); mSearchBox = (EditText) mHeaderView.findViewById(R.id.ebSearch); mSearchBox.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override// www . j a va2 s.c om public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { final String query = v.getText().toString(); Intent intent = new Intent(getActivity(), SearchActivity.class); intent.setAction(Intent.ACTION_SEARCH); intent.putExtra(SearchManager.QUERY, query); v.getContext().startActivity(intent); // Clear the box once searched v.setText(null); return true; } }); listView.addParallaxedHeaderView(mHeaderView); }
From source file:org.appcelerator.titanium.util.TiUIHelper.java
public static void setTextViewDIPPadding(final TextView textView, final int horizontalPadding, final int verticalPadding) { int rawHPadding = (int) getRawDIPSize(horizontalPadding, textView.getContext()); int rawVPadding = (int) getRawDIPSize(verticalPadding, textView.getContext()); textView.setPadding(rawHPadding, rawVPadding, rawHPadding, rawVPadding); }