I am using the getItemIdAtPosition() to get the Basecoulmns id of the record in Sqlite Database.
the code is below:
protected void onListItemClick(ListView l, View v, int position, long id) {
Cursor cursor = managedQuery(Constants.CONTENT_URI,
PROJECTION, BaseColumns._ID + "="
+ l.getItemIdAtPosition(position), null, null);
}
But its does not retrieves the id correctly. Is this method depends some thing at the time of setting adapter or creation of DB? I have no idea. why it shows the position of the listview. Any Idea?
Edit:
the code for getView mehod :
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mInflater.inflate(R.layout.brutube_videos, null);
holder = new ViewHolder();
holder.text1 = (TextView) convertView
.findViewById(R.id.vdo_text1);
holder.text2 = (TextView) convertView
.findViewById(R.id.vdo_text2);
holder.text3 = (TextView) convertView
.findViewById(R.id.vdo_rate_text);
holder.icon = (ImageView) convertView
.findViewById(R.id.vdo_icon);
convertView.setTag(holder);
} else {
holder.text1 = (TextView) convertView
.findViewById(R.id.vdo_text1);
holder.text2 = (TextView) convertView
.findViewById(R.id.vdo_text2);
holder.text3 = (TextView) convertView
.findViewById(R.id.vdo_rate_text);
holder.icon = (ImageView) convertView
.findViewById(R.id.vdo_icon);
}
if (!mBusy) {
try {
Log.v("getview", "" + (position) + " - " + VAL3[position]);
holder.icon.setImageBitmap(BitmapFactory
.decodeStream(new URL(VAL3[position])
.openConnection().getInputStream()));
notifyDataSetChanged();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
holder.icon.setTag(null);
} else {
holder.icon.setImageResource(R.drawable.no_video_icon);
// Non-null tag means the view still needs to load it's data
holder.icon.setTag(this);
}
holder.text1.setText(VAL1[position]);
holder.text2.setText(VAL2[position]);
holder.text3.setText(VAL4[position] + " Ratings");
return convertView;
}