Android GridView onitemdownclick - android

I'm using a GridView following this tutorial.
In my app, each image in the grid acts as a button that takes the user to another screen. That's all fine and dandy.
What I'm having trouble with is finding some way to darken the image once a user clicks down, and then lighten it again when the user releases it. onItemClickListener doesn't have an onItemDownClick function built in. What would be the best/most pain free way to create this functionality, or a similar function?

instead of CLICK use the TOUCH events (which have down and up and a lot of other stuff) and for the darkening and lightening I would use a semi opaque colored box that you show/hide depending on the situation.

Related

Android - Create a view that includes the entire screen

I am not the best at android programming so please correct any errors I make.
According to this developer.android.com.
Android view is:
This class represents the basic building block for user interface
components. A View occupies a rectangular area on the screen and is
responsible for drawing and event handling. View is the base class for
widgets, which are used to create interactive UI components (buttons,
text fields, etc.).
However, I have not found an article about how to get a full view. I mean as in an entire screen as a view. The image I used below is to show what I want to include in that view. I want to include everything on screen. Everything On that Screen. (I can't repeat enough). It includes the chat heads, background, and menu bar. Everything that is on screen.
I can't figure out how to get a view like that from a service or from an activity. Any help is appreciated. I don't have exact code because I don't know how to do this.
Edit:
I know that I am very bad at explaining, so if you are confused, I am going to explain what I want to do with my view.
So basically, I want to make a screen tapper that taps for you so you can king of "cheat" games like cookie clicker. Therefore I need a view that contains the entire screen so then I can fake "touches" on the screen.
Hope this cleared any confusion
So you have a few things to deal with. Generally, the menu bar (and possibly soft-key buttons on the bottom) will remain visible. However, you can hide the menu bar:
hide the top menu bar in my android device & Tablet
You may want gestures to allow users to see it. Or, since it appears you are building a game, you just leave it hidden until they hit "home" or "back" or "exit" or whatever.
The "chat heads" are a horrible idea, but some developers think they are awesome. You can see more about that here:
Creating a system overlay window (always on top)
You might find something like this will work (but if new notifications pop-up, it may not help):
http://goobbe.com/questions/1390940/how-to-close-cancel-dismiss-a-system-dialog-programmatically-android

In Android 4, how to do "toggle button" like behavior for other widgets?

I am new to Android, coming from a web app dev background. I have a HorizontalScrollView with a list of dynamically added ImageViews. When an image is clicked, it should be marked as selected, the image then should have an UI effect to reflect the state(a green border or a tick on bottom right corner), when it is clicked again, it should be deselected.
In web development, we could use css classes to reflect an item's ui state by checking whether it has a certain class.
How is it usually done in Android?
Thanks
Have you looked into ListView? There's no reason to write that kind of functionality all over again.

Images display in Android

I have list of images. what i want that when user clicks on one of the images then it should appear similar like following picture. user can see big image with blur background, and user can change this image by swiping finger(same like activity change). when user press back button it should be cancel. Is it possible in Android? I hope you understand my problem.
yes,you must define a customize dialog, and then open it when you want.
you can code for swipe finger or anything else you are looking for.
making and showing custom dialog here and as some guidance to you, use image view and you must use gesture detector here or here
enough ??

Placing a background picture and then having invisible touch (Android)

I am trying to make an application for android that is based on IPAD app. I want to keep the same look to the app, but I am not a very good designer. So I was wondering if it was possible to for me to crop say the entire header and then have an invisible button or something on top of portions of it. so the design would become a little bit easier. Also if that is possible how would I get the what ever the event item is going to be to overlap with a portion of the image if it has stranger orientation. (I think I could fake this by just moving it closest orientation and extending the size untill it fits, but it would be nice to find a better way.)
How would I go about that?
I tried making the button invisible, but that did not seem to work.
Thanks in advance
I got lost on your description. But if you want to make a button invisible, calling setVisibility(View.INVISIBLE); will not work, because it will not receive click events. You may want to set its color to transparent instead. try using:
button.setBackgroundColor(Color.TRANSPARENT);

How to control button flashing on Android PhoneGap app

I am writing a PhoneGap app on Android. I am trying to stay pure HTML+CSS+JS, without calling specific PhoneGap APIs. So the app is somewhat an embedded web page, more or less.
The page has some "buttons" on it, which are actually table cells with some CSS attributes (among which cursor: pointer) and an onClick function.
I have noticed that when I touch a button, it "flashes" for a second or so, then its corresponding action is performed. By the way, I don't like this very much, since it causes a delay in the UI.
Some of the "buttons" activate a menu. I handle the menu by making visible a semi-opaque black div that covers the whole screen, and above it a centered div containing a table containing the menu items. (the black div and the centered div are hidden, normally).
The problem is that when I touch a menu item, it does not flash; one of the underlying buttons flashes instead (that is, one of those that at the moment are covered by the semi-opaque black div, and are supposed to be inactive). Nevertheless, the correct action is performed, in other words the onClick function of the menu item gets called, not the one of the flashing button .
So my question is two-fold:
1) Is there a simple way to make the right item flash (I mean the menu item instead of the underlying, semi-covered button)?
2) Is there a simple way to totally disable button flashing, so that the UI would speed-up and problem 1 be solved too?
Many thanks
You should be using the touch events, which are supported on Android WebKit. This will prevent the select + touch behaviour that you're seeing on your HTML elements that the onClick event causes.
Android versions past Android 1.5 support touch events such as touchstart and touchend. I recommend using them, and reading Apple's documentation (yes, I know it's weird, but Google's Web App documentation is still poor with respect to touchevents.)

Categories

Resources