Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9071963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:03:14+00:00 2026-06-16T18:03:14+00:00

What i am doing is getting friends list from facebook and trying to populate

  • 0

What i am doing is getting friends list from facebook and trying to populate list view with friends name and his profile pic but no exception and error coming in logcat list is getting size of 56 and data is in the array list but not populating on UI don’t know why kindly suggest me the solution,here is my activity getFriendList Function code:

public List<Friend> getFriendList(){

        Request request = Request.newMyFriendsRequest(Session.getActiveSession(), new Request.GraphUserListCallback() {

            @Override
            public void onCompleted(List<GraphUser> users, Response response) {
                // TODO Auto-generated method stub
                for(int i=0; i<users.size();i++)
                {
                GraphUser user =    users.get(i);
                Friend objFriend = new Friend();
                objFriend.setFriendID(user.getId());
                objFriend.setFriendName(user.getName());
                //objFriend.setFriendPic(user.g)
                //objFriend.setFriendPic("http://graph.facebook.com/" + objFriend.getFriendID() + "/picture");
                friendsList.add(objFriend);
                Log.d("Friend's Id", objFriend.getFriendID());
                Log.d("Friend's Name", objFriend.getFriendName());
                //Log.d("Friend's Pic", objFriend.getFriendPic());
                Log.d("Friend's List Count", Integer.toString(friendsList.size()));
                }
            }
        });
        Request.executeBatchAsync(request);
        return friendsList;
}

and here is my onCreate function:

@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.friends_list);
        list = (ListView)findViewById(R.id.listview_friends);
        friendsList = getFriendList();
        friendAdapter = new FriendAdapter(this, R.layout.activity_friends, friendsList);
        list.setAdapter(friendAdapter);
    }

here is my custom adapter code:

public class FriendAdapter extends ArrayAdapter<Friend>
    {
        Context context;
        Friends holder;
        int layoutResourceId;
        List<Friend> friendList;
        Bitmap profilePhoto;

        public FriendAdapter(Context context, int layoutResourceId,List<Friend> friendList)
        {
            super(context, layoutResourceId, friendList);           
            this.context=context;
            this.layoutResourceId=layoutResourceId;
            this.friendList=friendList;
        }


        @Override
        public View getView(int position,View convertView,ViewGroup parent)
        {
            View row=convertView;

            if(row==null)
            {
                LayoutInflater inflater=((Activity)context).getLayoutInflater();
                row=inflater.inflate(layoutResourceId, parent,false);

                holder=new Friends();
                //holder.friendProfilePic=(ImageView)row.findViewById(R.id.ImageViewfriendProfilePic);
                holder.friendName = (TextView)row.findViewById(R.id.textViewFriendsName);

                row.setTag(holder);
            }
            else
            {
                holder=(Friends)row.getTag();
            }
//      
            holder.friendName.setText(friendList.get(position).getFriendName());
            //holder.friendProfilePic.setImageBitmap(profilePhoto);

            return row;
        }

here is my xml layout friends_list.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/listview_friends"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >
    </ListView>

</LinearLayout>

and here is activity_friends.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content" >

        <ImageView
        android:id="@+id/ImageViewfriendProfilePic"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dip"
        android:src="@drawable/com_facebook_button_grey_focused" />

    <TextView
        android:id="@+id/textViewFriendsName"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="100dip"
        android:layout_marginTop="20dip"
        android:text="TextView" />
    </RelativeLayout>



</LinearLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:03:15+00:00Added an answer on June 16, 2026 at 6:03 pm

    Don’t use list this way.

    friendsList = getFriendList();

    As the request was send and you got the result it may take time so declare your list object like this way

    List<Friends> friendList = new ArrayList<Friends>();
    

    just pass this array list as empty in adapter and set the adapter to the list

    friendAdapter = new FriendAdapter(this, R.layout.activity_friends, friendsList);
    list.setAdapter(friendAdapter);
    

    now use the AsyncTask class to get the data from web in background so the UI was not stop and it’ll be fetched in background

    UPDATED

    AsyncTask FetchFriendList = new AsyncTask<Void,Void,Void>(){
        private List<Friends> list;
        public void doInBackground(Void... param){
             list = getFriendList(); // call here your request
        }
    
        public void onPostExecution(Void result){
               friendList.addAll(list);
               friendAdapter.notifyDatasetChanged();
    
        }
    };
    

    call this in onCreate after adapter set

    FetchFriendList ffl = new FetchFriendList();
    ffl.execute();
    

    One more thing when you add/edit/delete item in list you must call notifyDatasetChanged(); and don’t too much add/delete within UI it may force close with large data

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Maybe I am doing something wrong but) I am getting awful read performance from
i'm getting json data from the facebook-graph-api about: my relationship with my friends my
I am using jQuery.getJSON to fetch the Facebook friends list, but I am not
I Believe I'm doing this correctly but it is not getting the stored cookie
I am working with Android Facebook SDK and wanted to get a friends list.
I'm using the Facebook API to pull a list of all of my friends.
I've been trying to learn templates in C++ but I'm getting a little confused
I'm looking for a quick way of getting all my friends's profile pictures. I'm
Doing the getting started of Sinatra. I get this error: ./sinatra.rb:5: undefined method `get'
I am getting started doing ASP.NET on my Mac using Mono, and I'm wondering

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.