Add Description or Hint to Button in android - android

How do add description or hint. When i touch a Button / ImageButton, I need description or hint.
Thanks in advance.

I am not sure this approach is a good idea since when you touch a Button in Android, it get's in pressed state, and when you release it will trigger the button's action. I suggest you use a different approach such as a properly formated TextView under the Button or ImageButton.

Related

Dissable a button on the screen - Android Studio

I hope youre doing well
I have some buttons with onClick events on it. But I also display a ListView and on the buttons zone the listview items can be "touch". So when the listview is display the buttons not only have to be invisible (using button_name.setAlpha(0)) but also they must be dissable. Can that be done?
Thanks in advance
Instead of using alpha, you should be using the visibility property of the button.
button_name.setVisibilty(View.INVISIBLE)
or
button_name.setVisibilty(View.GONE)
If you want to disable a button you can use
button_name.setEnabled(false)
Hope that helps!
hope this helps,
To enable button -
button.setClickable(true);
To disable button -
button.setClickable(false);

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

Adding a cancel button/icon on EditText with TextWatcher

I have an EditText with a TextWatcher attached to it and the onChangeText method works flawlessly.
I'd like to add a mini icon/button at the very right end of the EditText, which clears the text and then disappears.
May I have some direction on how to implement this? I don't want source code, but an idea on what mechanism to use. Thank you in advance.
I would say you have it in your Layout permanently as you want it to look but you normally have the Visibility set to GONE then just set it to VISIBLE when you want it shown.

Checkbox label should not be clickable

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.

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