I am trying to create a listview item with an imageview to the right of a textview.. lets say if the text was 3 lines i want the text of the first 2 lines to begin after the image view with some padding.. and the third line to be at the bottom of the image with no padding..
I used this code in my list adapter to do this..
TextView commenterName = (TextView) row
.findViewById(R.id.commenter_name);
commentText = (TextView) row.findViewById(R.id.tv);
ImageView commenterPhoto = (ImageView) row
.findViewById(R.id.commenterPhoto);
Display display = ((WindowManager) row.getContext()
.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
FlowTextHelper.tryFlowText(commentsArray.get(pos).getComment(),
commenterPhoto, commentText, display, 0);
commenterName.setText(commentsArray.get(pos).getCommenter());
commentText.setTextColor(context.getResources().getColor(R.color.Black));
commentText.setGravity(Gravity.RIGHT);
this working fine.. but when scrolling the list view the text loses its padding and get over the image and out of the screen..
UPDATE: This was the part causing the problem.. i put the else condition to set the default photo but the problem still exist..
String path = url.substring(url.lastIndexOf("/") + 1, url.length());
sd = new File(Environment.getExternalStorageDirectory()
+ Constants.user_images_path + path);
if (sd.exists()) {
Bitmap thumbnail = null;
try {
//File filePath = context.getFileStreamPath(url);
FileInputStream fi = new FileInputStream(sd);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize = 4;
thumbnail = BitmapFactory.decodeStream(fi, null, options);
if(thumbnail != null)
holder.commenterPhoto.setImageBitmap(thumbnail);
else
holder.commenterPhoto.setBackgroundResource(R.drawable.commenter_default);
} catch (Exception ex) {
Log.e("getThumbnail() on internal storage", ex.getMessage());
}
}
I don't know why this is happening.. Can you help me please?