spannablestring

How to Include clickable text in staticlayout and surfaceview

青春壹個敷衍的年華 提交于 2019-12-21 22:52:08
问题 I designing an interactive kids book. I am using a canvas on surfaceview since I need animations which I think are best suited to surfaceview I want to make each word touchable and read that word aloud. This worked great when I used a regular view with a textview inside. I then tried canvas for animations and do not know how to do it. I have used a staticlayout on the canvas to hold the spannable text. I do not know how I can activate the onTouchListener. Here I set up the staticlayout public

Use SpannableString in Android Home Screen widgets?

試著忘記壹切 提交于 2019-12-19 11:32:46
问题 Can I use SpannableStrings in a widget's textView? I tried and all it rendered was plain text. I don't know if it is something I'm doing wrong (most likely), or if it just isn't possible for some reason. Here's the code I'm using (nothing special really...) public static void updateWidgetState(Context paramContext, String paramString, Integer appWidgetId) { SpannableString majorLabel = new SpannableString(""); SpannableString minorLabel = new SpannableString(""); if (position > -1) {

Justifying text inside a TextView in android

人盡茶涼 提交于 2019-12-19 08:17:38
问题 So, as most of you know, there is no text justifying inside a TextView in Android. So, I built a custom TextView to get around the problem. However, for some reason, sometimes punctuation marks break the line for some reason in some devices. I tested on an LG G3 and emulator (Nexus 4 running latest version) and a comma "," for instance breaks the justification on the LG G3 but not on the emulator. If I add a Padding start and end (or left and right) of at least 2, the problem is solved. This

java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList

北慕城南 提交于 2019-12-19 05:25:27
问题 I'm using the phonegap Android plugin: EmailComposerwithAttachments https://github.com/phonegap/phonegap-plugins/tree/master/Android/EmailComposerWithAttachments and it occurs the following error when executing startActivitywithResult function. I'm using Android 4.2 with Cordova 2.5.0 java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList // setting attachments try { JSONArray attachments = parameters.getJSONArray("attachments"); if

java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList

北城余情 提交于 2019-12-19 05:25:10
问题 I'm using the phonegap Android plugin: EmailComposerwithAttachments https://github.com/phonegap/phonegap-plugins/tree/master/Android/EmailComposerWithAttachments and it occurs the following error when executing startActivitywithResult function. I'm using Android 4.2 with Cordova 2.5.0 java.lang.ClassCastException: android.text.SpannableStringBuilder cannot be cast to java.util.ArrayList // setting attachments try { JSONArray attachments = parameters.getJSONArray("attachments"); if

How do I achieve a Facebook Messenger/ Google Hangouts like layout to preview selected items in search bar on ANDROID?

给你一囗甜甜゛ 提交于 2019-12-19 03:53:12
问题 Basically what I want to create can be best illustrated from a screenshot. I have a listview of people just like FB Messenger app. I want the ability for my users to have a search bar like the one shown in the screenshots. It should have the following properties: 1) Search bar should preview names of people selected in the list view 2) People can be de-selected by hitting backspace on any name in the preview search bar 3) The search bar should be able to filter the bottom list of people as

Aligning ImageSpan to the top of the TextView

最后都变了- 提交于 2019-12-18 19:47:13
问题 Currently, I wish to add an image in between texts and align it to the top of the TextView. Something like this: The only vertical alignments I can find are baseline (which seems to put it right down the center of the text) and align bottom. What happens if I use ALIGN_BASELINE is: Is there a way to align it to the top instead? My current code: txtView.setText(this.addImageAsterisk( "The string to have asterisk at the end*"), BufferType.SPANNABLE); then private CharSequence addImageAsterisk

Why show java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String?

心已入冬 提交于 2019-12-18 14:43:11
问题 When copying String from any browser page, pasteData works properly. However when copying SpannedString from a message sent item editor(field), the application crashes and shows this error message: java.lang.ClassCastException: android.text.SpannableString cannot be cast to java.lang.String My code: // since the clipboard contains plain text. ClipData.Item item = clipBoard.getPrimaryClip().getItemAt(0); // Gets the clipboard as text. String pasteData = new String(); pasteData = (String) item

Creating softkeyboard with custom emoji

最后都变了- 提交于 2019-12-18 13:38:25
问题 I have been tasked to create a new android 3rd party keyboard that supports customized emojis (My own Icons) from assets. I want to implement a softkeyboard with my own emoji icons without using UniCode or my custom UniCode. Questions: If I create a custom emoji, with some string of characters which does not map to the standard set of emojis, and text this message to a friend with the customized app/keyboard, what shows up on their device? The regular ASCII characters string? or the image. I

Ellipsize individual lines of a SpannableString in a TextView

僤鯓⒐⒋嵵緔 提交于 2019-12-18 04:23:08
问题 I have a TextView storing an address that is two lines long. The street goes on the first line and is bold. The city & state go on the second line and are not bold. I want the end of each line ellipsized if the individual text on that line runs over. I'm using a SpannableString to store the address because I want the street address to be bold and the city & state to be not bold. Is there a way to do this that isn't a total hack without using two TextViews for each line? Example outputs: Ex: