textview

How to limit specific character in edit text?

烂漫一生 提交于 2020-04-16 05:47:50
问题 My question is that How to limit specific character in edit text? for example I want to limit # character using max. 3 times in edit text. How can I do this? Any advice or code sample please. thanks. 回答1: use this yourEditText.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if(count>3){ yourEditText.setEnabled(false); } } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) {

Allign TextView with the progress of progressbar

风流意气都作罢 提交于 2020-04-15 08:37:50
问题 How can I allign a TextView with the progress of a horizontal ProgressBar . I want to put a TextView right above the progress position of the ProgressBar . The progress might be changed. Also, I want the TextView to be kept in one line, although the text length might be changed. 回答1: In the parent layout which contains your TextView and Progress bar set the gravity to center so that it will keep both of them center alligned. <LinearLayout android:layout_width="match_parent" android:layout

TextView visibility change notification

十年热恋 提交于 2020-04-11 12:44:26
问题 I need to detect when a TextView is made visible and when its made invisible. Is there any way to do this in Android? I've to make some processing when a TextView in my application changes visibility. Actually, it's visibility is being updated at a number of places and I'm looking to avoid calls at all of these places. 回答1: I don't know if this will answer your question, but if you want to listen to textview visibility changes, I suggest customizing TextView and implement your own listener

How to make a drawable Shape programmatically (Android)

柔情痞子 提交于 2020-04-08 14:42:30
问题 i'm making a custom TextView (Java class) and i'm having trouble "to translate" the line (on "original TextView" xml) android:background="@drawable/myDrawableShape" to a java void to change the color of the "myDrawableShape" myDrawableShape.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ffafafaf" /> <corners android:radius="15dp" /> I'll get the color to set from a String, the void to change the color programmatically could be (for example) void

How to make a drawable Shape programmatically (Android)

给你一囗甜甜゛ 提交于 2020-04-08 14:42:07
问题 i'm making a custom TextView (Java class) and i'm having trouble "to translate" the line (on "original TextView" xml) android:background="@drawable/myDrawableShape" to a java void to change the color of the "myDrawableShape" myDrawableShape.xml <shape xmlns:android="http://schemas.android.com/apk/res/android" > <solid android:color="#ffafafaf" /> <corners android:radius="15dp" /> I'll get the color to set from a String, the void to change the color programmatically could be (for example) void

Convert number in textview to int

喜你入骨 提交于 2020-04-08 09:20:16
问题 So, I am messing around with java/android programming and right now I am trying to make a really basic calculator. I am hung up on this issue though. This is the code I have right now for getting the number thats in the textview and making it an int CharSequence value1 = getText(R.id.textView); int num1 = Integer.parseInt(value1.toString()); And from what I can tell it is the second line that is causing the error, but im not sure why it is doing that. It is compiling fine, but when it tries

assigning large string to textview.settext hangs UI

ぐ巨炮叔叔 提交于 2020-03-23 06:32:51
问题 I'm trying to show very large text (of length 850879) in textview, unfortunately when I assign text to textview, UI hangs for 8-15 seconds! How do we fix this issue? any idea? 回答1: Use Webview....instead of textview. Textview is not design to load large text. WebView webView; String html; webView.loadDataWithBaseURL("", html, "text/html", "UTF-8", ""); 回答2: Can you spilt the text in small chunks and provide it to a list view... That way ui will not be blocked for what's not visible 来源: https:

How to make deep link string clickable in android TextView

白昼怎懂夜的黑 提交于 2020-03-22 23:48:10
问题 How do I make a deep link string for example "myapp://product/123" clickable in android TextView. I know there are autoLink options like email, web and phone but there isn't any deeplink option. How do I make it clickable and launch the intent on click of that link? 回答1: you can do that by using ClickableSpan eg. ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View textView) { startActivity(new Intent(MyActivity.this, NextActivity.class)); } @Override public

How to make deep link string clickable in android TextView

随声附和 提交于 2020-03-22 23:43:59
问题 How do I make a deep link string for example "myapp://product/123" clickable in android TextView. I know there are autoLink options like email, web and phone but there isn't any deeplink option. How do I make it clickable and launch the intent on click of that link? 回答1: you can do that by using ClickableSpan eg. ClickableSpan clickableSpan = new ClickableSpan() { @Override public void onClick(View textView) { startActivity(new Intent(MyActivity.this, NextActivity.class)); } @Override public

Devices with Android + MIUI and setCustomSelectionActionModeCallback

[亡魂溺海] 提交于 2020-03-17 07:44:13
问题 I'm trying to create custom selection menu but it does not work on a device with rom MIUI and Android 6. The result is common menu with "copy" and "select all" items. On other devices and simulators under clean Android it works just fine. The code textViewTop.setCustomSelectionActionModeCallback(new android.view.ActionMode.Callback() { @Override public boolean onCreateActionMode(android.view.ActionMode mode, Menu menu) { Log.d(LOG_TAG, "onCreateActionMode"); return true; } @Override public