I have an Activity that consist in 3 buttons and a EditText, where I add (with EditText.append(String)) some text when the buttons are pressed... The problem is that i couldn't find the way to show the last text lines when they reach the lower limit of the EditText..
Sometimes it works, and the text go up as i add more text lines, but for example, when i touch the screen and move the EditText, it stays there..
The only "solution" that i found was the "scroller", but i don't understand how it works. Can anyone help me with this?
Thanks in advance.
It is not really the answer to the question, but for the ones that maybe have the same question as me:
I finally put a TextView in a ScrollView, and used the fullScroll(View.FOCUS_DOWN) functionality of the ScrollView.. This way i could see the end of the TextView.
I could do this because i didn't need to edit the text added.
Hope it helps.
Related
I have put ten edit text in scroll view when i click on edit text my keyboard appear. What i want when i click on edit text one its automatically show the edit text two which is right below the edit text one. I have used
android:windowSoftInputMode="adjustPan"
but none of them giving me the desired result and i think by doing this way i cannot acheive this.
Right Now I have to scroll manually or click on the next button. How to achieve this automatically as i have seen this functionality in many of the apps?
In your manifest, within the "activity" declaration for the Activity you need to resize, add
android:windowSoftInputMode="adjustResize"
If it doesn't work with your ScrollView you may need to implement a simple ListView.
i have an AutoCompleteTextView widget on the view. if it has input focus and I'm trying to change the text in there with:
txtField1.setText("test");
I'm getting suggestions list appears on the screen. How do I hide it? is it possible to update the text not showing suggestions?
I'll leave this here, in case someone needs it in the future, like I did.
yourAutoCompleteTextView.dismissDropDown();
will make the list with suggestions disappear from the screen.
I suggest some methods
1)If you want to make "test" like hint of autocomplete textView then do like this,
txtField1.setHint("test");
2)If you need to fill up the text view with "test" and also need to prevent the suggestion increase the threshold level for auto complete textview ,
txtField1.setThreshold(5);
if you use threshold it will show suggestion after 5 character (according to the code posted in above line). If you need try to set different word and also try to avoid suggestion , change the threshold dynamically based on length of string.
I am using checkbox in android and the state of checkbox is changing once i click on the text of the checkbox. "[CB] Text ". Is there any way to change this behaviour so that the state of checkbox will be changed once i click on the box and not the text.
Sorry this question would have already asked in the forum. But i was not able to find any queries related to this. Any suggestions would be really helpful for me.
-Thanks,
Ron...
The answer by jkhouw1 is the only way I can think of as well.
But please take a moment to make sure you really want this functionality. Every time you change the basic behavior of a, to the user, well know element you confuse more than you help. There are cases where you need such a change, but take a minute to make sure this is so!
Other than creating your own control, the easiest way would probably be to not display any text with the checkbox and in your layout use a textview for the text instead so you would have
[CB][TextView]
I think you are using [checkbox] [textview] in one layout tht is linear or relative,if i am right then set android:focusable = "false" android:clickable= "true" to checkbox.
i hope it will help you.
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.
I'm trying to make iPhone-style EditText element on android.
The one that will have an additional clear button appear on the right after text input.
Adding a new button is not a problem, but I'm a bit stuck with another thing.
A button occupies some space on the right part of EditText, and now characters display beneath the button. How to change maximum shown length of input for EditText?
I want EditText width to be N pixels, and editable area to be N-M pixels.
EditText.setWidth changes width for whole edit box.
EditText.setEllipsize should be the proper solution, but docs are empty, and as I see it truncates text based on some String value.
Applying a LengthFilter cut's the input length to number of characters.
Thanks in advance.
I suspect that android:drawableRight will save you a lot of pain.
Seems I've found a solution.
EditText.setPadding(l,t,r,b) seems to work fine, applying only for editable area
Try this : http://mytechead.wordpress.com/2012/02/07/create-ios-like-cleartextbutton-in-android/
This is a very old question, but thought I'd add my two cents for kicks. I'd probably use a 9 patch for this and set the content area to stop the text before it hits the button area.
This would require creating a custom view so that you can add a button in the desired position using relative layout so that it can be clicked to clear the edittext.
Alternatively you can use the compound drawables, but you would need to implement something like this
Handling click events on a drawable within an EditText so that you can handle the click events. Keep in mind that I doubt the button states (eg the down state) will work using this method.