Include a TextView and override the text

Include cannot be used to “overrride” children properties. It doesn’t know which type of layout you will include, it will only inflate it and add it to the current layout. To dynamically change the text, you need to do it in code. final TextView textView1 = (TextView) findViewById(R.id.menuTextView); textView1.setText(R.string.menu); final TextView textView2 = (TextView) findViewById(R.id.settingsTextView); … Read more

clickable word inside TextView in android

This should do the trick. Just change your edittext’s text in the OnClickListener. It may be able to be reduced but this should work. private void foo() { SpannableString link = makeLinkSpan(“click here”, new View.OnClickListener() { @Override public void onClick(View v) { // respond to click } }); // We need a TextView instance. TextView … Read more

re-setting a TextView height programmatically

You should change it via LayoutParams: LayoutParams params = (LayoutParams) textView.getLayoutParams(); params.height = 70; textView.setLayoutParams(params); EDIT You should not use sizes in pixels in you code, use dimensions for this: dimens.xml: <dimen name=”text_view_height”>50dp</dimen> In code: params.height = getResources().getDimensionPixelSize(R.dimen.text_view_height);

textview.getLineCount always 0 in android

I know this question is quite old, but in case anyone comes here looking for the actual answer: holder.text2.setText(arr2[position]); holder.text2.post(new Runnable() { @Override public void run() { int lineCnt = holder.text2.getLineCount(); // Perform any actions you want based on the line count here. } });

Custom cut/copy action bar for EditText that shows text selection handles

I figured out the answer to my own question; TextView (and therefore EditText) has a method setCustomSelectionActionModeCallback() which should be used instead of startActionMode(). Using this enables customisation of the menu used by TextView for text selection. Sample code: bodyView.setCustomSelectionActionModeCallback(new StyleCallback()); where StyleCallback customises the text selection menu by removing Select All and adding some … Read more

Android SpannableString set background behind part of text

If anyone’s having difficulty with Roosevelt’s code sample (I sure was, maybe because it’s Xamarin.Android?), here’s a translation into a more basic Android java version: public class RoundedBackgroundSpan extends ReplacementSpan { private static int CORNER_RADIUS = 8; private int backgroundColor = 0; private int textColor = 0; public RoundedBackgroundSpan(Context context) { super(); backgroundColor = context.getResources().getColor(R.color.gray); … Read more

Extra padding on TextView with HTML contents

The extra ‘padding’ you’re seeing, is in fact just a line break followed by another line break: When you dive into the Html.fromHtml(…) implementation, you’ll come across the following method that handles paragraph tags: private static void handleP(SpannableStringBuilder text) { int len = text.length(); if (len >= 1 && text.charAt(len – 1) == ‘\n’) { … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)