Make button visible if string visible? - android

I have some text in the strings, and when you swipe your screen, they will change. So I want to make a button visible only, if the 3. text is visible.
<item>for free</item>
<item>easy to use</item>
<item>lets start</item>
When the "let's start" appears on the screen, I want my button to appear also on the screen, but only, when this string is visible "lets start".
These strings are in a textview, and they coded to change for swipe.
How to make this?
I know we have to implent somehow setVisibillity. and maybe add a listener?

How about comparing current TextView text?
if(yourTextView.getText().toString().equals("let's start")){
yourButton.setVisibility(View.VISIBLE);
}
if i understood correctly that should work.

Related

Can EditText jump to next position (timer)?

My timer app (see picture below) seems like a EditText field where i can set numbers (from right to left). After setting one number it jumps to the one left to it (or if it is its end, it replaced the first number on the right). It also have leading zeros.
So i want to create something like this too, but not with a fixed amount of numbers. Is this possible with a editText or should i use TextView or another element? I tried to use EditText because on focussing it can open a Numpad (i don't want a fixed Numpad).

Change the value in a view on keeping a button pressed

Framework: Android
I have a TextView where I would like to change the text on keeping an ImageView pressed.
Note: I am not referring to changing the text on clicking the view, but on pressing the view and on the amount of time that it is pressed.
e.g. I press the image and the text becomes 2. Keep it pressed for another half a second and the text becomes 3.
I haven't found a similar question yet, yet if you have, please redirect me. Thank you.
Make use of OnTouchListener and run your number changing algorithm in ACTION_DOWN

Android moving edit text automitcally

I have three EditText views named edittext_one ,edittext_two and edittext_three. I have put these views in a ScrollView. These EditTexts are clearly visible on the screen until my keyboard is not open. Now, I click on edittext_one, which is at the top, and my keyboard appears. Then, it hides my edittext_two and edittext_three. I want to go edittext_two just little bit up when I am typing in edittext_one so that user can see edittext_two. Same is happen with edittext_three. When user click on edittext_two, edittext_three slightly move up so user can see it.
I have lots of EditText in a scrollView, but I have just explained here three.
Please don't suggest me to use adjust pan and adjust resize because it never solves my problem.
Here is the link I used for iPhone
Sliding UITextFields around to avoid the keyboard but how do I do this in Android?
Try adding a click listener on edittext_one that does this:
int top = edittext_two.getTop();
scrollView.scrollTo(0,top);

How to prevent the soft keyboard from displaying, or at least evict it once it does?

My app has an EditText that, when I click in it to enter text in the Emulator, brings up a soft keyboard. I don't want this confounded thing to begin with, but then, like the visiting loud-mouthed uncle in the plaid pants, doesn't want to go away, and it is blocking the button beneath it. How do I either (a) prorgrammatically prevent the soft keyboard from appearing or at least (b) evict it, albeit manually, when it pops up?
Provided that the user is not supposed to input text, but is able to click the EditText and then add text in some other way, you could change the EditText to a TextView and then apply the following three tags to it in the layout file:
style="#android:style/Widget.EditText"
android:editable="false"
android:focusableInTouchMode="false"
This will make it look like an EditText, but behave like a TextView.
Since you want the user to be able to write stuff in the EditText there are in my opinion two solutions:
Leave it be. To remove the keyboard, all you need is to hit the back button once and every Android user knows this. It's standard behaviour.
Wrap everything but the Button you say dissapears in a ScrollView. The ScrollView will then wrap its content to allow the Button to be shown in between the keyboard and the ScrollView.
Just set android:editable="false" for your EditText
The answer is to set the focus on an other View like a Button, TextView or similar:
// REQUEST FOCUS
viewName.setFocusableInTouchMode(true);
viewName.requestFocus();
I think what you really need is take a look at android:windowSoftInputMode attribute in Manifest.xml Look into this link.
You can specify the screen to pan/ resize to show the buttons that the input method might be blocking. Not allowing the keyboard to show will make the user unable to enter text at all!

iphone-style text edit on android

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.

Categories

Resources