Empty BulletSpan issue in android Edittext - android

I'm implementing a rich text editor. In that, when user clicks on bullet icon in toolbar, an empty bullet should be created with no character in it. But I can not achieve this by setting span on the cursor position. I have to add an unwanted space to do this. Using below code,
editable.insert(cursorPos, " ");
editable.setSpan(new BulletSpan(), cursorPos, cursorPos + 1,Spanned.SPAN_INCLUSIVE_INCLUSIVE);
I have also tried with LeadingMarginSpan but same result. I am getting the required feature, if the cursor is placed in first position of EditText or there is any text in that line. Also same problem persists in Numbered list also.
And the problem persists only for first bullet/Number in list. In subsequent bullet or numbered list item the span is working properly.
Can you please anyone help me how to implement empty bulletspan without any space or character ?
Thanks in advance...

Related

Android EditText in RecyclerView

I want to implement a search. But unfortunately edit text must be in recycler view. I have multiple types of items.
When user enters a letter I refresh whole adapter, searching is done locally. That means that keyboard disappears and edit text is losing focus, because of this constant updating.
I managed to fix it showing keyboard and focus an edit manually while binding.
if (item.inEditableMode) {
edit_text.requestFocus()
showKeyboard(edit_text)
}
But edit text works not that good as I expect. A problem can be seen when user types fast or wants to clear input.
Thanks for help.
Layout:
"unfortunately edit text must be in recycler view" - I bet it do NOT have to be a part of RecyclerView not part of Adapter list item View. better inspect your layout architecture instead of posted workarounds with hiding-showing (blinking) keyboard
besides that even when it must be then don't notify whole Adapter with notifyDataSetChanged(), instead use notifyItemChanged(...) - notify range of of your items, but not list item with EditText - it won't be redrawn, so keyboard should stay visible and focus kept on that field. still this isn't good approach, your EditText should be separated from RecyclerView almost for shure

Focus between EditText and ListView item

My row in list that has editText in it, beside other things. If I set android:focusableInTouchMode="false" on editText, I am able to select my entire row, highlight it, get data I need, but I no longer can edit my editText, because keyboard doesn't pop up. If I set android:focusableInTouchMode="true", then I can edit editText, but i can't click on entire row, highlight it, get data. How can I achieve both?
ListView isn't adapted for inputs. It keeps in memory only visible items + 2. So even if you will achieve the that what you want, all your edits will dessapear after every time, your EditText leaves the screen.
Take a look at RecyclerView view documentation. This class is better adapted to this kind of stuff.
UPD
Actually, there is a tutorial exactly for foucsable EditTexts in ListView. But as you see, it was relevant for 2011.

Scroll text inside MultiAutoCompleteTextView programmatically

I want to create something similar to the Instagram search bar for messages, where I can add recipients as chips just pressing to the some user item from the suggestions list. My problem is the position of the cursor in the MultiAutoCompleteTextView. When I add last token, I want the text scroll a bit left to give area for the cursor to allow the user to type and see what he is typing. But in my case my cursor is on the border of the screen. It is not very convenient and looks not very good. The first image is the my implementation using https://github.com/splitwise/TokenAutoComplete library. The second image is from the Instagram. Please, tell me any possible solutions how can I scroll text inside MultiAutoCompleteTextView programmatically?

Set position of edit text cursor based on user touch position Android

I try to make some kind like note application in android xperia or samsung galaxy...
What I wanna do is to set the cursor of edit text position follow the touch position from user.
In normal edit text whenever we touch the edit text area, cursor will always positioned at the end of our characters or between the characters..
So The notes is some kind like being appended with many characters so we can move the cursor wherever we want...
I've tried to appended many blank spaces. but it wont help... Cursor only can move on 1 line only..
Is there any solution for this?
Thanks before.....

Android Edit Text Cursor position issues

I am making a text editor in android, I am using a multi-line edit text that holds all the text and all the editing is done on the same edit text.
I have one issue:
When i started working on the application, the cursor kept on the first position of the edit text. every time i use to enter text, the cursor did not move, rather the text kept on adding.
then i used this short piece of code to bring the cursor at the end of the edittext
edittext.setSelection(edittext.getText().length());
Now the problem is that i am unable to edit any text that has already been written in the edittext, as when i ever i try to edit it, the cursor jumps to the last position.
What i want is that my cursor should move to the position where i want to add or edit text. it is not allowing me to do that right now.
Additional things:
I am using a text watcher and all of the functionalities are being implemented in the text watcher. secondly i am using post function in onResume of my activity to implement certain functionalities.
use append method for this, it will show the cursor at the last :
etEditText.append("Text here");

Categories

Resources