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 8563029
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:51:56+00:00 2026-06-11T16:51:56+00:00

I have this code inside my BaseAdapter Adapter: public View getView(final int position, View

  • 0

I have this code inside my BaseAdapter Adapter:

public View getView(final int position, View convertView, ViewGroup parent) {
   View vi=convertView;

   if(convertView==null) 
       vi = inflater.inflate(R.layout.facebook_friends_layout, null);

   TextView friendsName = (TextView)vi.findViewById(R.id.tvFacebookName); // Friends thumb
   friend_image=(ImageView)vi.findViewById(R.id.ivFacebookPicture);  // thumb image

   song= new HashMap<String, String>();
   song = data.get(position);
   friendsName.setText(song.get(MyFriends.KEY_FBNAME));
   //Log.i("Facebook Pangalan", ""+MyFriends.KEY_FBNAME);

   FriendName = (String) friendsName.getText().toString();

   FBID = song.get(MyFriends.KEY_FBID); 
   String fbAvatarUrl = "http://graph.facebook.com/"+ FBID +"/picture";
   //Log.i("FBID", FBID);
   BitmapManager.INSTANCE.loadBitmap(fbAvatarUrl, friend_image, 100,100);
   Button btn=(Button)vi.findViewById(R.id.btnAdd);
   if (FBID.equals(""))
   {
       btn.setVisibility(View.GONE);
   }
   else 
   {
       btn.setVisibility(View.VISIBLE); 
   }
   btn.setOnClickListener(new OnClickListener(){ 

       public void onClick(View arg0) {
           LOCK_BASEDATA = MyFriends.LOCK_BASEDATA;
           if (LOCK_BASEDATA.equals("0")) 
           {
               //FACEBOOK FRIENDS
               Log.i("", ""+FriendName);
               //AddfromFacebookFriends();
           }
           else if (LOCK_BASEDATA.equals("1"))
           {
               //MY REQUEST
               //((MyFriends)context).SetMyRequest();
               //Log.i("LangYa", "Langya");
           }
           else if (LOCK_BASEDATA.equals("2"))
           {
               //FRIEND REQUEST
               //((MyFriends)context).SetFriendRequest();
               //d2papasok
               AddFriendRequest();
           }

       }

    });

   return vi;
}

I am logging my friend’s name whenever I click on the button. Now my problem starts when I click the button; I am not getting my desired string. It is getting the string from another row of my listview.

EDIT
Thanks, actually ive just aaded this code

public void onClick(View arg0) {
                LOCK_BASEDATA = MyFriends.LOCK_BASEDATA;
                if (LOCK_BASEDATA.equals("0")) 
                {
                    //Object x =btn.getTag();
                    //String sa = x.toString();
                    View parentView = (View) arg0.getParent();
                    String textviewtext = ((TextView) parentView.findViewById(R.id.hiddentv)).getText().toString();
                    //FACEBOOK FRIENDS

                    AddfromFacebookFriends(textviewtext);

                }
                else if (LOCK_BASEDATA.equals("1"))
                {

I am just getting my parents View to get my desired textview and now it works. Thanks anyway

  • 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-11T16:51:58+00:00Added an answer on June 11, 2026 at 4:51 pm

    You are trying to get the FriendName using this code:

    TextView friendsName = (TextView)vi.findViewById(R.id.tvFacebookName);
    FriendName = (String) friendsName.getText().toString();
    

    This is not The FriendName of the ListView item you clicked. Its the FriendName of the newly created ListView item. Because in getView(), the ListView item you get is the newly created one.

    One way to solve this is:

    Use tags like KunalK suggested. I am not sure if it works…i never tried it.

    Or the other way is:

    onButtonClicked get the Position of the ListView item you clicked, and get the respective Name from the ArrayList you are using.

    Here the Position is not the position parameter in the getView(). That gives the position of the newly created ListView item again.

    Use this to get the actual position of the clicked item:

    int clickedItemPosition = yourListView.getPositionForView((View) yourButton.getParent());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code inside a header (edited): template <int i> class A {};
I have this code inside a iframe: window.addEventListener('message', function(e){ if(e.data == 'test') console.log(e); },
I have this code inside thread and when I call terminate it terminates fast
So I have this code inside my lib/ folder: class GlobalConfig::SetHelper def self.yes_no_input(configuration) value
I have this code snippet inside a function that checks if an object exists
I have written this code inside a servlet to delete certain records from three
I have this block of code inside a loop: var points = [new google.maps.LatLng(lat1,
I have this code that shows all the images inside 'images' directory but it
I have this code which will include template.php file from inside each of these
I have a jsp page which needs a java code. This java code inside

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.