OnTouchEvent vs. OnClickEvent

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

OnTouchEvent vs. OnClickEvent

Postby ryank » Wed Mar 12, 2008 7:29 pm

When should I use OnTouch vs. OnClick? Is it when someone "touches" the screen and drags a certain distance?
User avatar
ryank
Developer
Developer
 
Posts: 43
Joined: Mon Jan 28, 2008 3:23 am

Top

Postby ryank » Thu Mar 20, 2008 2:00 am

I have made my 'buttons' as clickable ImageViews and tried ImageButtons with a background of @drawable/id, but the problem is when they are clicked, the user doesn't know. If I set the background color to YELLOW when it is clicked, it remains yellow.

Is there a way to just have it be yellow when pressed?
User avatar
ryank
Developer
Developer
 
Posts: 43
Joined: Mon Jan 28, 2008 3:23 am

Postby ryank » Fri Mar 21, 2008 3:17 am

Any ideas?

Also, I haven't been able to get OnLongClick to work either... no matter how long I hold it. anyone else have any luck?
User avatar
ryank
Developer
Developer
 
Posts: 43
Joined: Mon Jan 28, 2008 3:23 am

Postby CHAKYANAS » Fri Mar 21, 2008 5:28 am

HI ..ryank
the same problem i had ...................
but if you holds the keypad center key a long time it ll responds... ahtever code u wrote in long click will get executed on holding the center keypad buttonn..........

Just try for touchpadEvent
User avatar
CHAKYANAS
Developer
Developer
 
Posts: 44
Joined: Mon Mar 03, 2008 5:08 am
Location: INDIA

Postby CHAKYANAS » Fri Mar 21, 2008 5:35 am

hi ryamk ,,,
reply to ImageButton


you have to set the background image to some other color after clicking also.....
means you have type code inside imagebutton click to change again its background.....
so when clicking one color will display after resetting the previous color will display
User avatar
CHAKYANAS
Developer
Developer
 
Posts: 44
Joined: Mon Mar 03, 2008 5:08 am
Location: INDIA

Postby dkkundudolan » Wed Nov 26, 2008 9:02 am

Hi CHAKYANAS,

I have done what you said, color is changing in background of the ImageButton. but Original color of image button is not changing.
To do that, i kept two Image button with two different colors (red and green), so when i will click on the red color image button, 1 dialog box will appear(as i set like that) after clicking on the dialog box, the Image color has to be changed to green color.
Instead of that, in background another color is coming.
Can you tell me, how to do that?
Please reply me......

Thanks.
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Top

Postby dkkundudolan » Thu Nov 27, 2008 4:57 am

Hi,

Now i can click the Images . And color also changing. Now i want to change the color of the Image in another way.
Here in the 1st page i have the Image, textView and Button in same LinearLayout. (img1 in attachment). when i will click the "arrow" button in the right side of the screen, it will move to the next page (img2 in attachment). In the 2nd screen, when i will click the checkbox and after that when i will click on "Done" button, it will come back to the 1st screen.
Here on the 1st screen, the Image color will be changed as i selected the checkbox and also with that it will display with Implants that "one " or "two" items are selected. (The Implants will be like this : "Implants(1/2)", if one check box selected."Implants(2/2)", if two checkboxes are selected).
and for the color change, i kept two ImageButton with different colors. So by selecting the checkbox, the Image color will be changed.

Please can anybody give a little suggestion how to do that?
Hope a reply.

Thanks in advance.
Attachments
img2.pdf
(27.75 KiB) Downloaded 261 times
Img1.pdf
(25.35 KiB) Downloaded 203 times
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Postby CHAKYANAS » Thu Nov 27, 2008 1:40 pm

can you please explain correctly the problem
User avatar
CHAKYANAS
Developer
Developer
 
Posts: 44
Joined: Mon Mar 03, 2008 5:08 am
Location: INDIA

Postby dkkundudolan » Fri Nov 28, 2008 4:39 am

Hi CHAKYANAS,


Here in the 1st page i have the Image, textView and Button in same LinearLayout. (img1 in attachment). when i will click the "arrow" button which is in the right side of the screen, it will move to the next page (img2 in attachment). In the 2nd screen, Check boxes are there . so when i will click the checkbox and after that i will click on "Done" button, so it will come back to the previous screen (img1 screen in attachment).

So after coming back to the 1st screen ,the Image color of the 1st screen (img1 screen in attachment)will be changed as i selected the checkbox for the next screen (img2 in attachment) and also with that it will display with Implants that "one " or "two" items are selected. (The Implants will be like this : "Implants(1/2)", if one check box selected."Implants(2/2)", if two checkboxes are selected).
and for the color change, i kept two ImageButton with different colors. So by selecting the checkbox in the (img2 in attachment), the Image color will be changed (in img1 in attachment).

I think , now i can clear you.

How to do that? please any idea...............

Thanks.
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Postby CHAKYANAS » Mon Dec 01, 2008 5:17 am

hai,

I am assuming that u dnt have any problem in recognising which check box is selected in page 2, when u come back to 1st page,(if any , then declare one variable in ist page activity as Public static then access it in 2nd page and change the value inside checkBoxSelectec(),and compare tyhe value of this vraible in the 1st page . and you can use VISIBILITY property to set and unset the two image button.
User avatar
CHAKYANAS
Developer
Developer
 
Posts: 44
Joined: Mon Mar 03, 2008 5:08 am
Location: INDIA

Postby dkkundudolan » Tue Dec 02, 2008 9:57 am

Hi CHAKYANAS,

In this case, it is not the right way to make Visible or invisible the Imagebutton.
Anyway i did that.

Thanks for help.
dkkundudolan
Experienced Developer
Experienced Developer
 
Posts: 83
Joined: Mon Mar 03, 2008 12:50 pm

Top

Return to General

Who is online

Users browsing this forum: No registered users and 6 guests