I have a textView which is configured as an EditText. But the problem is that the cursor doesn't appear when i'm pressing keys (text is written correctly).
Thanks
Well the first thing I'd try is setCursorVisible(true)
Also you say you have a TextView which is configured as an EditText. That's a bit confusing to me. Did you define it in your layout XML as <EditText> or create a new EditText object via new EditText(context)? Or did you define it as a <TextView> with android:editable="true"? Your wording sounds almost like you did the later, but I'm not sure that's going to work as well as the former.
For future reference, posting the code that's not working as part of your question really helps people pinpoint your problem and provide you the correct answer.
Related
Is there a way to make a textfield (EditText, TextView) on Android which displays copyable text (no edit options)? Something like Swing's JTextField().setEditable(false) on Windows?
Edit: It seems that my question was a little bit unclear, so I'm going to give it some real-world context. I am working on a checksum calculator which lets you pick a file and prints the results of the calculation into 4 different textfields. I want the user to be able to copy those hashes from the textfield, but to disable all edit options.
I believe what you are asking is very straightforward and simple, if I am reading your question wrong, please correct me!
Are the four text fields that hold the results required to be EditText 's?
otherwise - >
Question:
How to make TextView only copyable, not editable
Answer:
Well using a TextView solves the not editable part
and if you take a look
at my android studio. I have a simple TextView with an attribute of
textIsSelectable="true"
allowing users to copy and paste!
Hope this helped!
-Stephen
I have several textviews in my application, sometimes it looks messing, like below:
In normal case, it shoule be like this:
Anyone met this before? Thanks:)
Seemed the customized ROM made some changes to the framework, and the textview buffer is not well cleared before set the new text.
I solve this by setting empty text before setting the real text.
By the way, why my post got the minus point....
I am looking to achieve the functionality of an AutocompleteTextView but slightly different. Instead of getting a drop-down list with suggestions i want it to complete the sentence for me.
For example: i type abc and i get completed, with the rest of the text in grey: abc1#etc.etc and then click a button to keep this text or keep writing to filter this even further.
Do you think is is achievable somehow?
I have looked my problem up so far but all the answers i found involved a drop-down list, perhaps i haven't looked deep enough.
Why don't you try to implement a custom view?
Basically, you need to the same things that the AutoCompleteTextView does but instead of displaying N elements into the drop down list you have to add the first option to your EditText.
Have a look at:
TextWatcher in order to see how detect the user input and progress
You can then play with indexes and spannables in order to keep track of the data input by the user and the data that you are suggesting.
One thing that I don't like about this idea is the fact that if you have got:
Germans
Germany
...
You need to type a lot of letters without the possibility to choose something different from the solution that you are providing.
use below example ... i think help you...
http://teamandroid4u.blogspot.in/2012/06/autocompletetextview-example.html
So I'm new to Android development and I'm currently figuring out TextWatcher.
What I'm attempting to do is attach my TextWatcher listener to an EditText widget and after the user has put in some text, say "Hello" and he highlights "llo" and types in r, I display the change in a TextView widget. For the above example it will display "llo --> r".
Now from what I've read and tried, since the textchangelistener is called every time the user types in something, my code ended up crashing when I ran it on my phone.
Is there a way to call the listener only when the highlighted text is changed so as to avoid calling it every time I'm just typing something in the EditText widget? I hope my question makes sense, I've tried looking around before posting here but I couldn't find anything.
Not looking for code, just some pointers so I can figure out how to do this.
Thanks!
Your best bet would be to use a OnEditorActionListener instead of a textwatcher which I didnt know existed until now. It gets called when there is a change to a textview, and since edit text is a textview than it will work perfectly.
Heres some info on the listener
Btw welcome to the android platform, I think you'll find that it is a rich language and definitely worth learning. If you really want some pointers your main point of reference should be this link which has many guidelines and pointers in the develop tab. Good luck
First, let me say, new to java, new to android. I'm attacking this head- with an ambitious first real project, a special kind of text editor.
I have figured out styling using spannables, but thats not particularly important.
I need a dynamic margin inside edittext. when I click the button, I want it to indent all of the text after that, on both left and right, until there is a carriage return, then it should drop back to no indent on a new line.
Think dialog in a play for an example of the output.
Thanks in advance for any information you might lend.
The answer in this post (look at the OLD ANSWER part) should help you solve the margin problem, but you can't have two different margins in one edit text. Consider creating a new edit text when a user presses carriage return or something of the sort.
Hope it helps.