[android-developers] Re: Fwd: listview getting stuck while scrolling,

2012-02-22 Thread moktarul anam
Hi Vani,

I  Have gone through your code and problem is in image fetching
portion. Fetching images from server and display part you do it in
android asynctask task.

Fetching part you do in  doInBackground method and  in onPostExecute
add that image into view. Always you will remember .. for all server
interaction you have to use  asynctask task or thread or handler
otherwise ANR( android not responding) error will come

(http://developer.android.com/reference/android/os/AsyncTask.html)

Enjoy
Moktarul Anam



On Feb 22, 3:36 pm, vani reddy vani.reddy.bl...@gmail.com wrote:
 -

 Hi friends,

 In the LazyAdapter class i am sending an object which consists of an
 arraylist , while scrolling the listview it gets stuck and shows the
 infamous ANR dialog.
 This is the listview in xml

   ListView
             android:id=@+id/android:list
             android:layout_width=fill_parent
             android:layout_height=wrap_content
             android:layout_margin=5dip
              android:background=@android:color/transparent
             android:cacheColorHint=#
             android:divider=@android:color/darker_gray

             android:scrollbars=none
             android:fastScrollEnabled=true
             
 Below is thegetView method
 @Override
     public View getView(final int position, View convertView, ViewGroup
 parent) {

         String name = ;

         ViewHolder holder;

         if (convertView == null) {
             convertView = mInflater.inflate(R.layout.commentitem, null);

             holder = new ViewHolder();
             holder.reviewText = (TextView) convertView
                     .findViewById(R.id.reviewText);

             holder.fbImage = (ImageView)
 convertView.findViewById(R.id.fbImage);

             convertView.setTag(holder);
         } else {

             holder = (ViewHolder) convertView.getTag();
         }

         String profilePictureURL = http://graph.facebook.com/;
                 + cList.getData().get(position).getFbid() + /picture;

         if (cList.getData().get(position).getName() == null) {
             name = ;
         } else {
             name = cList.getData().get(position).getName() +  says ;
         }

         holder.reviewText.setText( + name
                 + cList.getData().get(position).getComment());

         try {
             Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new
 URL(
                     profilePictureURL).getContent());
             holder.fbImage.setImageBitmap(Utility.getRoundedCornerBitmap(
                     bitmap, 10));
         } catch (MalformedURLException e) {
             e.printStackTrace();
         } catch (IOException e) {
             e.printStackTrace();
         }

         return convertView;
     }

 How to resolve this??

 --
 Regards,
 Vani Reddy

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Re: Fwd: listview getting stuck while scrolling,

2012-02-22 Thread vani reddy
Yeah correct ,it really worked ..Thanks..

On Wed, Feb 22, 2012 at 4:19 PM, moktarul anam mokta...@gmail.com wrote:

 Hi Vani,

 I  Have gone through your code and problem is in image fetching
 portion. Fetching images from server and display part you do it in
 android asynctask task.

 Fetching part you do in  doInBackground method and  in onPostExecute
 add that image into view. Always you will remember .. for all server
 interaction you have to use  asynctask task or thread or handler
 otherwise ANR( android not responding) error will come

 (http://developer.android.com/reference/android/os/AsyncTask.html)

 Enjoy
 Moktarul Anam



 On Feb 22, 3:36 pm, vani reddy vani.reddy.bl...@gmail.com wrote:
  -
 
  Hi friends,
 
  In the LazyAdapter class i am sending an object which consists of an
  arraylist , while scrolling the listview it gets stuck and shows the
  infamous ANR dialog.
  This is the listview in xml
 
ListView
  android:id=@+id/android:list
  android:layout_width=fill_parent
  android:layout_height=wrap_content
  android:layout_margin=5dip
   android:background=@android:color/transparent
  android:cacheColorHint=#
  android:divider=@android:color/darker_gray
 
  android:scrollbars=none
  android:fastScrollEnabled=true
  
  Below is thegetView method
  @Override
  public View getView(final int position, View convertView, ViewGroup
  parent) {
 
  String name = ;
 
  ViewHolder holder;
 
  if (convertView == null) {
  convertView = mInflater.inflate(R.layout.commentitem, null);
 
  holder = new ViewHolder();
  holder.reviewText = (TextView) convertView
  .findViewById(R.id.reviewText);
 
  holder.fbImage = (ImageView)
  convertView.findViewById(R.id.fbImage);
 
  convertView.setTag(holder);
  } else {
 
  holder = (ViewHolder) convertView.getTag();
  }
 
  String profilePictureURL = http://graph.facebook.com/;
  + cList.getData().get(position).getFbid() + /picture;
 
  if (cList.getData().get(position).getName() == null) {
  name = ;
  } else {
  name = cList.getData().get(position).getName() +  says ;
  }
 
  holder.reviewText.setText( + name
  + cList.getData().get(position).getComment());
 
  try {
  Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new
  URL(
  profilePictureURL).getContent());
  holder.fbImage.setImageBitmap(Utility.getRoundedCornerBitmap(
  bitmap, 10));
  } catch (MalformedURLException e) {
  e.printStackTrace();
  } catch (IOException e) {
  e.printStackTrace();
  }
 
  return convertView;
  }
 
  How to resolve this??
 
  --
  Regards,
  Vani Reddy

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en




-- 
Regards,
Vani Reddy

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en