Hi,
I am using an adapter to customize a gallery view.
Within the adapter I use getView to show the gallery items
the way I want (with frames and rounded corners).
Works fine, except one thing and I cant find how to do it -
I cant find a way to draw the 'focused' and 'pressed' state.
So my question is - how do I detect when a gallery has the focus,
and how do I instruct the adapter to draw, say a focus ring around the
image.
The adapter code follows:
//
==================================================================================
public class iBarAdapter extends BaseAdapter {
int myDX;
private Context mContext;
private LayoutInflater mInflater;
public iBarAdapter(Context c, int dx) {
mContext = c;
myDX = dx;
mInflater = LayoutInflater.from(c);
}
public int getCount() {
int res = g_nNumberOfSpeeds;
return res;
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup
parent) {
IbarHolder holder;
int theIcon;
boolean bPressed,bFocused;
if (position>=g_nNumberOfSpeeds) return null;
if (convertView == null) {
convertView = mInflater.inflate((myDX==80)?
R.layout.ibar_item:R.layout.ibar_item_w, null);
holder = new IbarHolder();
holder.background = (ImageView)
convertView.findViewById(R.id.IbarBackground);
holder.image = (ImageView)
convertView.findViewById(R.id.IbarImage);
holder.icon_back = (ImageView)
convertView.findViewById(R.id.IbarFieldIconBackground);
holder.icon = (ImageView)
convertView.findViewById(R.id.IbarFieldIcon);
convertView.setTag(holder);
} else {
holder = (IbarHolder) convertView.getTag();
}
// Image:
Bitmap b = null;
Uri contactUri = People.CONTENT_URI;
if ((mSpeeds.get(position).contactID!=null) &&
(mSpeeds.get
(position).contactID.length()>0))
{
contactUri = Uri.withAppendedPath(contactUri,
mSpeeds.get
(position).contactID);
b = People.loadContactPhoto(mContext,
contactUri, 0, null);
}
if (b==null)
{
holder.background.setImageResource(R.drawable.no_image);
} else {
holder.background.setImageBitmap(b);
}
// rounded corners frame on top of image:
holder.image.setImageResource(R.drawable.ibar_back);
// Icon:
holder.icon_back.setImageResource
(R.drawable.ibar_icon_back);
theIcon = GetPhoneFieldIconFromLabel(mSpeeds.get
(position).label);
holder.icon.setImageResource(theIcon);
return convertView;
}
}
//
==================================================================================
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---