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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T06:52:08+00:00 2026-06-18T06:52:08+00:00

I am trying to use notifyDataSetChanged , to update my list view in order

  • 0

I am trying to use notifyDataSetChanged , to update my list view in order to change one row in it from password dots, to plain text and back to password dots.

In my adapter (changed it based on a comment here ) I check the type of the object that I have in that row. If the row is a password I set it to

setTransformationMethod(new PasswordTransformationMethod()); 

in order to turn the password text to dots. Later in my activity a click on that row will change it type to “notPass”, and I am trying to refresh my listview with notifyDataSetChanged to represent it as a visible text.

public class UserAccountAdapter extends ArrayAdapter<UserAccountData> {
    Context context;
    int layoutResourceId;
    UserAccountData data[] = null;
    TreeSet<String> mSeparatorsSet = new TreeSet<String>();

    public UserAccountAdapter(Context context, int layoutResourceId,
            UserAccountData[] data) {
        super(context, layoutResourceId, data);
        this.layoutResourceId = layoutResourceId;
        this.context = context;
        this.data = data;
    }

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

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

            holder = new UserAccountDataHolder();
            holder.imgIcon = (ImageView) row.findViewById(R.id.imgUserAccountIcon);
            holder.txtTitle = (TextView) row.findViewById(R.id.txtTitle);


            row.setTag(holder);
        } else {
            holder = (UserAccountDataHolder) row.getTag();
        }

        UserAccountData userAccountData = data[position];
        holder.txtTitle.setText(userAccountData.title); 
        //hold

er.txtTitle.setTransformationMethod(new PasswordTransformationMethod());
            holder.imgIcon.setImageResource(userAccountData.icon);
        if(userAccountData.type.equals("pass")){

            ((TextView) row.findViewById(R.id.txtTitle)).setTransformationMethod(new PasswordTransformationMethod());
        }
        else{
            ((TextView) row.findViewById(R.id.txtTitle)).setTransformationMethod(null);
        }


        return row;
    }

    static class UserAccountDataHolder {
        ImageView imgIcon;
        TextView txtTitle;
    }
    }

The object that I am giving the adapter is:

public class UserAccountData {
    public int icon;
    public String type;
    public String title;
    public UserAccountData(){
        super();
    }

    public UserAccountData(int icon, String title, String type) {
        super();
        this.icon = icon;
        this.title = title;
        this.type = type;
    }
    public void setType(String type){
        this.type = type;
    }

}

And my activity part that deals with the clickListener is:

 usersArray = new UserAccountData[user_data.size()];
 user_data.toArray(usersArray);

 final UserAccountAdapter adapter = new UserAccountAdapter(this,
                                        R.layout.user_accounts_row, usersArray);

 userAccountsListView = (ListView) findViewById(R.id.userAccounts);
 userAccountsListView.setAdapter(adapter);

 userAccountsListView.setOnItemClickListener(new OnItemClickListener() {
        @Override
            public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            if(adapter.getItem(position).type.equals("pass")){
                adapter.getItem(position).setType("notPass");
                adapter.notifyDataSetChanged();


            }
            else if(adapter.getItem(position).type.equals("notPass")){
                adapter.getItem(position).setType("pass");
                adapter.notifyDataSetChanged();

            }

Right now when I am clicking on a password field with dots, that field remains dotted and some but not all of the other fields that are of type user/email/phone are also turning into dots

Any idea what am I doing wrong?

UPDATE: solved the issue.
1) needed an else if, and not if / if.
2) changed the adapter based on one of the comments

  • 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-18T06:52:09+00:00Added an answer on June 18, 2026 at 6:52 am

    In your adapter class in the getView Method you don’t reset the transformation for fields with type ‘no pass’.

    if(userAccountData.type.equals("notPass")){
            holder.txtTitle.setTransformationMethod(null);
        }
    

    Instead of directly using the position as an array index, you could get the associated data with the ‘getItemAtPositionMethod’

    listView.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
    
            UserAccountData uad = (UserAccountData)parent.getItemAtPosition(position);
                //your code
    
            });
    

    Try to set values directly in each getView call:

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        UserAccountDataHolder holder = null;
    
        if (row == null) {
            LayoutInflater inflater = ((Activity) context).getLayoutInflater();
            row = inflater.inflate(layoutResourceId, parent, false);
        }
    
        UserAccountData userAccountData = data[position];
        TextView tvTitle = (TextView) row.findViewById(R.id.txtTitle);
    
        if(userAccountData.type.equals("pass")){
            tvTitle.setTransformationMethod(new PasswordTransformationMethod());
        }
    
        if(userAccountData.type.equals("notPass")){
            tvTitle .setTransformationMethod(null);
        }
     }
    

    }

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

Sidebar

Related Questions

I'm trying use mod_rewrite to rewrite URLs from the following: http://www.site.com/one-two-file.php to http://www.site.com/one/two/file.php The
I'm trying to use a list view, and when I add an item to
Trying to use Powershell to script the removal of specific custom errors from an
I'm trying use Places API from Google frmo a node.js server This is the
I'm a little confused here, I am trying use a partial view in a
I'm trying use the FormWizard for to submit an order charge in wizard done
Im trying use the spinner control result in order to point it to another
I am trying use std::copy to copy from two different iterator. But during course
I'm trying use to selenium with firefox on CentOS from command line like this:
I'm trying to use in my Android Application the notifyDataSetChanged() method for an ArrayAdapter

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.