10 messages in com.googlegroups.android-developersRe: How to know which component got s...
FromSent OnAttachments
Mohan Parthasarathy16 Jan 2008 09:47 
Romain Guy16 Jan 2008 09:58 
Mohan Parthasarathy16 Jan 2008 13:17 
Romain Guy16 Jan 2008 13:42 
Mohan Parthasarathy16 Jan 2008 15:56 
Anthony17 Jan 2008 20:46 
Mohan Parthasarathy18 Jan 2008 09:12 
plusminus02 Feb 2008 10:43 
Bala12 Feb 2008 01:11 
Mohan18 Feb 2008 17:51 
Subject:Re: How to know which component got selected ?
From:Bala (bala@gmail.com)
Date:02/12/2008 01:11:12 AM
List:com.googlegroups.android-developers

Hi Mohan,

Have you ever tried with ImageSwitcher onclick event..?

Thanks and Rgards, Balaji.

On Feb 2, 11:44 pm, plusminus <stoe@gmx.de> wrote:

Hello Mohan Parthasarathy ,

I'm receiving the same NullPointerException internally thrown from GridViews 'MoveSelection'...

Did you find a solution ??

Regards, plusminushttp://anddev.org #  Worlds largest Android Development Community / Tutorials

On Jan 18, 6:13 pm, "Mohan Parthasarathy" <suru@gmail.com> wrote:

Hi,

The getId() scheme seems to work for me.

I am having a different problem. The Gridview contains photos in my example. In OnItemSelectedListener, i get the view set to null when i select any of the photos ? Also, i am unable to setadapter multiple times on a gridview. Has anybody done this ?

thanks mohan

On Jan 17, 2008 8:46 PM, Anthony <xjh2@gmail.com> wrote:

You can set every button with different tag, and getTag() in OnClickListener to check who it is. By this solution, all buttons can use the same OnClickListener.

On Jan 17, 7:57 am, "Mohan Parthasarathy" <suru@gmail.com> wrote:

Ah!  i was following a wrong example. When i try to select the first bitmap image in my grid, the gridview disappears. And in my handler the view is set to "null". I just return doing nothing when view is null, and the gridview goes blank.

Also, in my application i am calling setAdapter with a new set of Imageview/bitmaps whenever "next" button is pressed. If i call it the second time, a null pointer exception occurs in  Gridview.moveSelection which i  not in my code..

-mohan

On Jan 16, 2008 1:42 PM, Romain Guy <roma@google.com> wrote:

There is no need to call a method on the parent since the clicked View is passed to you as a parameter. Refer to the documentation of AdapterView.OnItemClickListener for more details.

On Jan 16, 2008 1:18 PM, Mohan Parthasarathy < suru@gmail.com>

wrote:

On Jan 16, 2008 9:58 AM, Romain Guy <roma@google.com> wrote:

Hi Mohan,

When a click happens, the onClick(View view) method of the OnClickListener interface is invoked. This method receives one argument which is the View that was clicked. You could then simply check the instance (for instance view == myButton) or the ID ( view.getId()) of this parameter to know what View was clicked.

In the case of the GridView, you should use the setOnItemClickListener().

I have a grid of photos (ImageView) and in OnItemSelected  i am using parent.obtainItem. I am unable to cast the value to ImageView, View etc. I am getting a ClassCast exception. What is the right thing to cast the return value of the obtainItem ?

thanks mohan

On Jan 16, 2008 9:47 AM, Mohan Parthasarathy < suru@gmail.com> wrote:

Hi,

My view has multiple buttons (Ok, Next, back) which has almost very similar work and hence i want to share the Onclick handler. How do i know which button was selected in the handler ?

Also, i have a grid view with multiple bitmap images. Is it possible to know which one is selected when the user clicks on it ?

Thanks mohan