On Wed, Feb 22, 2012 at 11:58 AM, rhaazy <[email protected]> wrote:
> I have a question related to how the tutorial is asking me to
> structure my code.
> The code is from a tutorial where I create a gridview and set up a
> click listener event:
> gridview.setOnItemClickListener(new OnItemClickListener() {
>                public void onItemClick(AdapterView<?> parent, View v,
>                                                 int position, long id) {
>                        Toast.makeText(HelloGridViewActivity.this, "Position: 
> " +
> position, Toast.LENGTH_SHORT).show();
>                        }
>        });
>
> To me this structure is kind of messy, what I would like to do is have
> the function, public void onItemClick be by itself, so that I can do
> something more along the lines of: (psudo code)
> gridview.setOnItemClickListener([somehow reference the function
> here]);
>
> Is what I'm asking possible?

You are welcome to have your Activity implement the
OnItemClickListener interface, in which case onItemClick() would be a
method on the Activity, and you would call
gridview.setOnItemClickListener(this); to make the connection.

> Does my question make sense?

Yes.

> Is there a more appropriate group to ask this kind of question?

Not really, though you are also welcome to use StackOverflow with the
android tag.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android Training...At Your Office: http://commonsware.com/training

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to