How can I set on the screen, the 'onClick' method 'setSoundEffectEnabled(false)'? - java

My ConstraintLayout has an OnClick method, so every time the screen is touched, i works like a button. But the problem here is that I need to get rid of the default sound button but the setSoundEffectEnabled(false)' ONLY works for actual button views.
Any ideas?

Related

Change EditTextPreference background color if empty

In my settings activity, I want to check if the Edittextpreference is empty, before exiting the activity, clicking on the android.R.id.home button or on the back button of the device. If the edittextpreference is empty, I have to do something, like change its background color, and avoid the user to exit settings. But the problem is that if i have two edittextpreference, and only one is empty, one edittextpreference has to be with different background, and the other needs to be as it was.
Is there any way to do this? Maybe if it is not possible using the equivalent of edittext.setError()?

Textview animation works only once on Android Studio

There is a button and when it is clicked on I want a message to slide to right and then fade away. It works only the first time this certain layout is loaded. This is what I've written
popTextView.animate().translationX(popTextView.getWidth()).alpha(0.0f).setDuration(1500);
Set repeat rount for your animation.
animation.setRepeatCount(Animation.INFINITE);
or
animation.setRepeatCount(5);
try calling YourView.getAnimation().start(); while clicking on button

Why doesn't EditText get focus with setFillAfter(true)?

So when you have the visibility set to INVISIBLE on the EditText fields it doesn't want to get focus for the keyboard.
I fixed this issue by changing the visibility on those fields after the animation completes like this:
edit_text.setVisibility(View.INVISIBLE);
final Animation fadeInAnimation = AnimationUtils.loadAnimation(getActivity(), R.anim.fade_in_view);
fadeInAnimation.setFillAfter(true);
edit_text.startAnimation(fadeInAnimation);
edit_text.setVisibility(View.VISIBLE);
But I want to know why it doesn't get focus. Shouldn't setFillAfter(true) set them to visible again?
The description for setFillAfter(boolean fillAfter) says
If fillAfter is true, the
transformation that this animation
performed will persist when it is
finished.
When set to true it does do this
An animation on Android does not actually animate the View itself, it
animates a bitmap representation of the View
Check out: Animation.setFillAfter/Before - Do they work/What are they for?

Android change in view - Button state gets reset

I have a button which is basically used for start/stop. So initially the text of the button is set to start. I attached a OnClickListener to it. So whenever it gets clicked i change its text. So if it was start it become stop and vice-versa.
The problem comes when i change my phone view from portrait to landscape or vice-versa the button text gets reset.
So for example I clicked the start button---it changed to stop. Now if I tilt my phone to change the view the button text gets set to start again.
Am I using the button in a wrong way?
You should save your button state. When screen orientation changes, onCreate is called and all your app variables are re-intitialized. Read more here http://developer.android.com/reference/android/app/Activity.html
No, you are using the button in the right way.
The thing what you are seeing is "configuration change". When you are tilting your device, Android recreating your activity and recreating all it's views (so, they getting default captions as them described in XML).
You need to do the
disable configuration changes for your Activity. To do so, add the following to your manifest's activity tag: android:configChanges="orientation|keyboardHidden". It is not suitable, if you have different layouts for landscape and portraint orientations, when you need to...
handle the configuration changes by overriding onSaveInsatnceState method of your Activity, save a state there and then use it in onCreate method.
See this article for further explanation

Can I show up the textbox editor on an image icon in Android?

all,
We know on Andorid, for a EditText, by default, whenever the EditText is clicked, the soft keyboard pops up to let you enter text. When you click DONE, it closes out and put the text directly to the EditText.
Now, what I am trying to do is, instead of an EditText, I have an ImageView which is to let user enter some comment.(So the ImageView actually is an comment icon). I wish whenever the icon is clicked, it pops up the text editor with user previous entered text, again once the DONE is hit, it closes out and I can save whatever text there back to a string member of the Activity. Is that possible?
So far, all I've seen about InputMethodManager is on EditText control, If it is too complicated, I probably just put an EditText into a sperate Activity.
Thanks.
There are many solutions:
One is to use custom dialog: http://developer.android.com/guide/topics/ui/dialogs.html#CustomDialog
Second one is to use a transparent activity on top of that one.
Then you could use FrameLayout and insert another view in an exact position...
I think you should try the frist or second one. Every ImageView can be easily converted into a button by adding onClick event to it.

Categories

Resources