Hi everybody,
I really need a help on this point because its the only thing not working in my app. I have a listview managed by an adapter that is extending BaseAdapter.
In the getview function im using the convertView to set up a OnClickListener. This OnClickListener work well when I am touching the screen but if I use the trackball of the HTC Desire, I see the row flashing on the screen, but the OnClickListener is not called...
I've read the android dev guide : http://developer.android.com/guide/topics/ui/ui-events.html and its say that I should receive a onClick event from the trackball...
Im putting here my getview code in case someone see anything strange. If you have any idea on what I can do, please let me know.
public View getView(int position, View convertView, ViewGroup parent) {
//ici on va utiliser un mécanisme de cache avec le Tag Holder
MyTag holder;
if (convertView == null){
//On se branche sur le bon layout
// convertView = inflater.inflate(android.R.layout.simple_list_item_2, null)
convertView = inflater.inflate(R.layout.twolines, null);
holder = new MyTag();
//on récupère les éléments du layout dans le holder
holder.txtData = (TextView)convertView.findViewById(R.id.productTitle);
holder.txtExtra = (TextView)convertView.findViewById(android.R.id.text2);
holder.imgScreenshot = (ImageView)convertView.findViewById(R.id.Screenshot);
holder.imgFlag = (ImageView)convertView.findViewById(R.id.Flag);
//holder.mLoginButton = (LoginButton) convertView.findViewById(R.id.login);
holder.mPostButton = (ImageView) convertView.findViewById(R.id.postButton);
//sauvegarde du holder
convertView.setTag(holder);
} else {
holder = (MyTag)convertView.getTag();
}
//Facebook post button management
holder.mPostButton.setOnClickListener((OnClickListener) new OnPostClickListener(convertView.getContext(),mFacebook, Long.toString(data[position].videoId), data[position].title, data[position].publisher, data[position].imageUrl));
holder.mPostButton.setImageResource(com.cedemo.scan.utils.getPostButtonResId());
//data update
if(data[position].title != null)
holder.txtData.setText(data[position].title);
if(data[position].publisher != null)
holder.txtExtra.setText(data[position].publisher);
//get and set the language flag
if(data[position].language != null)
holder.imgFlag.setImageResource(com.cedemo.scan.utils.getFlag(data[position].language));
//set the screenshot
if(data[position].myVideoScreenshotBm != null)
holder.imgScreenshot.setImageBitmap(data[position].myVideoScreenshotBm);
/* =================================================================
THIS FUNCTION IS NOT CALLED WHEN I CLICK ON THE TRACKBALL
BUT IS CALLED WHEN I TOUCH THE SCREEN.
WHEN I USE THE TRACKBALL THE SELECTED ROW IS FLASHING ONCE.
================================================================= */
//set the click mechanic if there is a valid video url
if(data[position].url != null) {
convertView.setOnClickListener((OnClickListener) new OnProductClickListener(position));
}
return convertView;
}