Usually on the Android OS when something is touched like a button or list item it makes a touch tone or sound. I have a custom made AdapterView (DevsmartLib) that basically creates a horizontal list view for me, however, none of the items make sounds when touched. I'm wondering if anyone knows what settings or options control whether a touch ends up triggering a sound or not. Any help or pointers are highly appreciated.
Thanks,
Harry
I think this SO-thread answers your questions.
You can use the xml attribute soundEffectsEnabled, or its corresponding java method, and after that you can play sound effects using Sound Effect Constants in the playSoundEffect method. This could also be done with MediaPlayer, but I don't think that's the kind of sound you want.
This developer page on multimedia might help if you want other kinds of sound.
Related
I want to add custom audible feedback to a button press (various click sounds encoded as *.ogg) I've done this by using the RingtoneManager to create Ringtones for each of the clicks and then .play() them in the onClick() method. This works but seems a little sluggish. This leaves me wondering if there is a better way to attach a custom sound effect to a button press. I've scanned the Button reference page and all I found was playSoundEffect() which seems to handle only system defined sounds.
thanks,
hank
Use a SoundPool- they work it preloads the data into memory (so no file reads which cause sluggishness). Ringtones are definitely not what you want to be using here- those are typically much longer and not time critical (delaying a ringtone by a second or so isn't a problem, whereas delaying a button sound effect by that long is).
my question is not only about onTouch events but about every method I can use to recognise a touch on certain areas of the screen.
Right now, I have a "background" image, which I use as layout that contains 2 "buttons": Start and Options as you can see here:
Ok, what I want to know is which is the best way to identify when are the user touching each button. By the way, should be nice also some info about how to deal with the different screen sizes.
Lots of thanks.
PD: seems I didnt explain it well. they are not "Android buttons" theirselves. The background is a whole image, where you can find 2 "buttons", but they are a part of the image. Thats because I need to know how to do this
I think you're missing some fundamentals, so I recommend to take a tutorial track.
As a direct answer to your question , you can see this page from the tutorial.
Why do you want to set the touchListener on whole screen and find the buttons?..You can simply set the OnClickListener or onTouchListener on both the buttons itself..
I have a volume knob and would like to know how to make it respond to user input in android. Please point me in the right direction as i have no idea how i can go about it ? Custom Knob looks like something created in this article. My question is what would be the general approach to port this knob into an android application. Do i have to extend the view class and draw this as a Bitmap. If so how exactly would i respond to user input. If this is not possible and i am on the wrong track could someone please tell me how to achieve this?
I would extend the View class.
View is the baseclass for widgets in android (by widgets I mean textfields, buttons, etc), so I think a volue knob would fit right in among those. About the user input, I'm not so sure. I think it depends on how you want to control the knob. I think looking at the onTouchEvent(MotionEvent) would be a good start. My guess is that you will need to overload a similar method anyways.
Related links:
http://developer.android.com/reference/android/view/View.html
http://www.vogella.com/articles/AndroidGestures/article.html
I have a need to create a circular dial/rotary style component for use in an application. It's essentially a circular menu that allows users to select from the items that are ringed around it, and then they can click the button in the center to activate the selected item. However, I've never created a custom UIView of this type, and don't really know where to begin. Can anyone give me any pointers as to how I would draw the view and then rotate it as the user drags their finger? I obviously know how to intercept touch events, etc. but I'm not sure how to actually go about manipulating the UI appropriately. Any tips or pointers would be great!
I don't know if you've already found a solution to this, but here is a nice overview of how to get started:
http://shahabhameed.blogspot.com/2011/05/custom-views-in-android.html
For you, I think you can extend an existing View, that View being the SeekBar. You can take the standard SeekBar and draw it in a circle.
Finally, here is a source code that does the rotation with a volume knob. It is its own project though, so you have to do some work to use it in your own app.
http://mindtherobot.com/blog/534/android-ui-making-an-analog-rotary-knob/
Good Luck!
I have a neat library to do this. It is extremely stable and well maintained. https://bitbucket.org/warwick/hgdialrepo
Heres a youtube demo: https://youtu.be/h_7VxrZ2W-g
This library comes with a demo app with source code and the demo app actually uses a dial as a menu, So I think this should be the perfect solution for you.
I have a button that plays a sound clip when it is pressed. I would like the button to appear pressed during the duration of the sound clip. By that, I mean that I would like the button to take on the default pressed-button appearance while the sound is playing. How can I implement this? I have tried using a number of things in the onClickListener (such as setSelected, requestFocus, etc), but none of those do the trick. I have also tried changing the onClickListener to an onTouchListener, again with no dice. Am I wrong in assuming that there must be a way to simply set the button image to appear pressed? (BTW, the button object is of type Button, not ImageButton).
Thanks for any advice!
Please see this question. It details a couple of different ways this can be done.
Lookup 'selector' drawables and let android take care of this for you.