TextView value changes back to previous value after scroll in base adapter

后端 未结 3 575
深忆病人
深忆病人 2021-01-27 02:58

I\'ve been researching this forever and can\'t find a solution. Everything about my custom list view seems to perform correctly. When I click on the holder.feedUpVoteButto

3条回答
  •  轮回少年
    2021-01-27 03:29

    After continuous trial and error. I finally figured out how to change a textview after it scrolls. My problem was I was getting the wrong ParseObject value. My main activity contains a ParseQuery and I was getting the likesfrom a Hashmap(); However, for some reason I couldn't pass the value of likes directly so I passed the ParseObject itself. Therefore, needing no query in my BaseAdapter Class. Then, I implemented these lines of code in GetView(); to answer my original question:

       holder.upvote[position] =  holder.parseObList[position].getBoolean(ParseUser.getCurrentUser().getUsername() + "upvoteClicked");
        holder.downvote[position] =  holder.parseObList[position].getBoolean(ParseUser.getCurrentUser().getUsername() + "downvoteClicked");
    
        if(holder.upvote[position]  ){
            holder.feedUpVoteButton.setBackgroundResource(R.drawable.arrowclicked);
            holder.feedNumOfLikes.setText(String.valueOf(holder.likes[position]));
    
        }
        else if(!holder.upvote[position]){
            holder.feedUpVoteButton.setBackgroundResource(R.drawable.arrowunclicked);
            holder.feedNumOfLikes.setText(String.valueOf(holder.likes[position]));
    
    
        }
        if(holder.downvote[position]){
            holder.feedDownVoteButton.setBackgroundResource(R.drawable.arrowclicked);
    
        }
        else if(!holder.downvote[position]){
            holder.feedDownVoteButton.setBackgroundResource(R.drawable.arrowunclicked);
    
        }
    

提交回复
热议问题