title: How to use autocompleteTextview widget on android to return string from an arraylist
body: <p>This is my current app, I am able to return the String name of different countries</p>
  
  <pre><code>package com.example.autocompletetutorial;
  
  
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  import android.widget.ArrayAdapter;
  import android.widget.AutoCompleteTextView;
  
  public class MainActivity extends Activity {
  
      String[] countries = {"Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", 
              "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", 
              "Austria", "Azerbaijan", "Bahamas", "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", 
              "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia", "Bosnia and Herzegowina", "Botswana", "Bouvet Island", 
              "Brazil", "British Indian Ocean Territory", "Brunei Darussalam", "Bulgaria", "Burkina Faso", "Burundi", "Cambodia", 
              "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", 
              "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Congo, the Democratic Republic of the", 
              "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia (Hrvatska)", "Cuba", "Cyprus", "Czech Republic", "Denmark", 
              "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", 
              "Eritrea", "Estonia", "Ethiopia", "Falkland Islands (Malvinas)", "Faroe Islands", "Fiji", "Finland", "France", 
              "France Metropolitan", "French Guiana", "French Polynesia", "French Southern Territories", 
              "Gabon", "Gambia", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", 
              "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard and Mc Donald Islands", 
              "Holy See (Vatican City State)", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", 
              "Iran (Islamic Republic of)", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", 
              "Kazakhstan", "Kenya", "Kiribati", "Korea, Democratic People's Republic of", "Korea, Republic of", "Kuwait", 
              "Kyrgyzstan", "Lao, People's Democratic Republic", "Latvia", "Lebanon", "Lesotho", "Liberia", 
              "Libyan Arab Jamahiriya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Macedonia, The Former Yugoslav Republic of",
              "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", 
              "Mauritius", "Mayotte", "Mexico", "Micronesia, Federated States of", "Moldova, Republic of", "Monaco", "Mongolia", 
              "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", 
              "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "Northern Mariana Islands", 
              "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", 
              "Pitcairn", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russian Federation", "Rwanda", 
              "Saint Kitts and Nevis", "Saint Lucia", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Sao Tome and Principe",
              "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia (Slovak Republic)", "Slovenia", 
              "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "Spain", "Sri Lanka",
              "St. Helena", "St. Pierre and Miquelon", "Sudan", "Suriname", "Svalbard and Jan Mayen Islands", "Swaziland", "Sweden", 
              "Switzerland", "Syrian Arab Republic", "Taiwan, Province of China", "Tajikistan", "Tanzania, United Republic of", "Thailand", 
              "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", 
              "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", 
              "Uruguay", "Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Virgin Islands (British)", "Virgin Islands (U.S.)",
              "Wallis and Futuna Islands", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"};
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
            ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(this,
                    android.R.layout.simple_dropdown_item_1line, countries);
              AutoCompleteTextView textView = (AutoCompleteTextView)
                      findViewById(R.id.autocomplete);
              textView.setAdapter(adapter);
              textView.setThreshold(1);
  
  
  
  
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.main, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/uYQUm.png" alt="enter image description here"></p>
  
  <p>However I need a arraylist base on the following java</p>
  
  <pre><code>    public class User 
      {
         // attributes
         private String accountID;
         private String companyName; 
         private String designation; 
         private String firstName; 
         private String lastName; 
         private String profileimageBLOB;
  
         // behaviors
         public User()    // default constructor
         {
             // attributes will be initialized to their default values
         }
  
         public User(String accID ,String comName, String design, String fName, String lName, String image) // parameterized constructor
         {
             accountID = accID;
             companyName = comName;
             designation = design;
             firstName = fName;
             lastName = lName;
             profileimageBLOB = image;
         }
  
         // set and get methods
         public void   setAccountID(String accID) { accountID = accID; }
         public String    getAccountID() { 
            return accountID; }  
         public void   setCompanyName(String comName) {companyName = comName; }
         public String getCompanyName() { 
            return companyName; }
         public void   setDesignation(String design) { designation = design; }
         public String    getDesignation(){ 
            return designation; }
         public void   setFirstName(String fName) { firstName = fName; }
         public String    getFirstName(){ 
            return firstName; }
         public void   setLastName(String lName) { lastName = lName; }
         public String    getLastName(){ 
            return lastName; }
         public void   setProfileImage(String image) { profileimageBLOB = image; }
         public String    getProfileImage(){ 
            return firstName; }
  
  
         // toString() method
         public String toString()
         {
            return  firstName + "\t" + lastName + "\t" + profileimageBLOB;
         }
  
  
      }
  
  How can I edit the app, to help me display the appear Photo and firstName, last Name from the arraylist, instead of everything?
  </code></pre>
  
  <p>That is what I intend to do
    <img src="https://i.stack.imgur.com/OSHAd.jpg" alt="enter image description here"></p>
  
  <pre><code>import java.util.ArrayList;
  import java.util.HashMap;
  import java.util.Iterator;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.text.Editable;
  import android.text.TextWatcher;
  import android.widget.ArrayAdapter;
  import android.widget.EditText;
  import android.widget.ListView;
  
  public class MainActivity extends Activity {
  
      // List view
      private ListView lv;
  
      // Listview Adapter
      ArrayAdapter&lt;String&gt; adapter;
  
      // Search EditText
      EditText inputSearch;
  
  
      // ArrayList for Listview
      ArrayList userList = new ArrayList();
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
  
          User p = null;
  
          p = new User("1", "Starhub Pte Ltd","Manager","Jason", "Bourne","");
          userList.add(p);      
          p = new User("2", "Singtel Pte Ltd", "Senior Manager","Ben", "Chia","");
          userList.add(p);  
          p = new User("3", "Ngee Ann Polytechnic", "Senior lecturer","Charles", "Xavier","");
          userList.add(p); 
          p = new User("4", "Dreamcity Pte Ltd", "","Ben", "Chia","");
          userList.add(p); 
          p = new User("5", "DBS Corporation", "Secretary","Michelle", "Chong","");
          userList.add(p); 
          p = new User("6", "OCBC bank", "Deputy finance Manager","YongZheng", "Wong","");
          userList.add(p); 
  
  
          lv = (ListView) findViewById(R.id.list_view);
          inputSearch = (EditText) findViewById(R.id.inputSearch);
  
          // Adding items to listview
          adapter = new ArrayAdapter&lt;String&gt;(this, R.layout.list_item, R.id.name_list, userList);
          lv.setAdapter(adapter);  
          //new line 
          inputSearch.addTextChangedListener(new TextWatcher() {
  
              @Override
              public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                  // When user changed the Text
                  MainActivity.this.adapter.getFilter().filter(cs);   
              }
  
              @Override
              public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                      int arg3) {
                  // TODO Auto-generated method stub
  
              }
  
              @Override
              public void afterTextChanged(Editable arg0) {
                  // TODO Auto-generated method stub                          
              }
          });
  
      }
  
  }
  </code></pre>
  
  <p>How can I improve from my mainactivity class? I need to display the photo the left side beside the result of the search.</p>