Hi all,

I'm kind of new to android development. I have read from many sources
that findViewById() is a "costly" operation. I'm making an application
that deals with 5 TextViews to provide different kinds of information
(distance, duration, title, description, etc) from a database. I'm
using listeners to catch touch/click events and feedbacks a handler.
The main function of the handler is to received a "position" in the
Cursor where the new information needs to be displayed.

I mentioned earlier that findViewById() is a "costly" operation. So, I
don't call this method in the handler. Doing so, it will retrieve
every time the Views when user touchs/clicks some widget.

Is it right to populate the Activity with private members of the
Views/Layout it displays? I mean, I don't like it. I don't know why,
but seems that I'm populating too much the activity. I'm aware of the
android:onClick xml attribute, but in my case I also use long click
listeners. So, a piece of onCreate() looks like:

imageTitle  = (TextView)findViewById(R.id.title_image_view);
title             = (TextView)findViewById(R.id.title;
desc           = (TextView)findViewById(R.id.desc);
duration     = (TextView)findViewById(R.id.duration);
distance     = (TextView)findViewById(R.id.distance);

And all of those are private members, wihout mention the
"cursor.getColumnIndex()" for each. I thought on implementing
Handler.Callback and set on the Hanlder.Callback constructor
implementer a View array or a View list or something, but I also need
this objects later to set other listeners and setups.

Is this right? I cannot think another way, as I need the reference to
the object, and also the Cursor reference that the handler will move
to the "position" provided and update the correspondent View.

I will really appreciate either an advice or a useful link/info/doc to
read in what concern in this kind of designs. What I do not like is
that It looks like imperative programming filling the Activity with
"global" variables.

Thanks,
-- 
If you want freedom, compile the source.

Sebastián Treu
http://labombiya.com.ar

-- 
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