Hi friends,
I've user's list fragment with Follow/unfollow button.Button is only one , 
I'm changing the state of buttons according to the status of 
follow/unfollow(server)
All the functions are working perfectly except from the state of button.
When I'm clicking on the "Follow" button i want to change the button's 
state <"true"> and also the text shuld be "Following".
Once click on the "Following" change the state <"false"> and Text should be 
"Follow"
I'm using TAG to check the follow/unfollow state with Button

     if(followStatus == true ){
                followBtn.setText("Following");
                followBtn.setTag("followed");
                followBtn.setSelected(true);
     }else {
                followBtn.setText("Follow");
                followBtn.setTag("unfollow");
                followBtn.setSelected(false);
     }

I've implemented the buttonClickListener,

     followBtn.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {

     UserValidator.getPermission(user.getID(), CrumbsSession.getUserID());
     if(UserValidator.permissionStatus == true ){
     Toast.makeText(activity, "You almost fooled us there :)", 
Toast.LENGTH_SHORT).show();
     }else{         
         final String u = user.fullName;
          
        if(followBtn.getTag() == "followed") {
                
         try {
     String id = userID ;
     final User user = new User(userID, activity);
         user.unfollow(new CrumbsResponse() {
            @Override
            public void onSuccess() {
         followBtn.setText("Follow");
                     followBtn.setSelected(false);
         followBtn.setTag("unfollow");
                     user.followStatus = false;
                     Toast.makeText(activity, "unfollowed -" + u, 
Toast.LENGTH_SHORT).show();
         super.onSuccess();
            }
     });
        } catch (IOException e) {
        } catch (JSONException e) {
        }
            
            }else{
          
             try {
     String id = userID ;
     final User user = new User(userID, activity);
         user.follow(new CrumbsResponse() {
            @Override
            public void onSuccess() {
         followBtn.setText("Following");
                     followBtn.setSelected(true);
         followBtn.setTag("followed");
                     user.followStatus = true;
                     Toast.makeText(activity, "Following - " + u , 
Toast.LENGTH_SHORT).show();
         super.onSuccess();
            }
     });
        } catch (IOException e) {
        } catch (JSONException e) {
        }
        
            }//end of if-else
     }
     
        }
     });
                      
                      //add view according to the request
           if(WHO == FOLLOWERS){
     followersUserListLinearLayout.addView(rowView);
     }else if (WHO == FOLLOWING_USERS){
     followingUserListLinearLayout.addView(rowView); //add items to linear 
layout         
     }


Inside fragment , I've created my own ArrayAdapter to add list of user's in 
linearlayout.
The above code is working in ArrayAdapter with the Activity.But when I'm 
using inside fragment it fails to change the button state.


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

Reply via email to