title: Custom Adapter ListView Error
body: <p>I am trying to list some user detail in a <code>Listview</code>, in each row show 4 String.</p>
  
  <p>The String is got from <code>Firebase</code>.</p>
  
  <p>I always get some error. Any idea about the reason of the error or any other solution?</p>
  
  <p>This is my code:</p>
  
  <p>MainActivity</p>
  
  <pre><code>public class SearchActivity extends AppCompatActivity {
  
      private ListView mListView;
      //public ArrayList&lt;String&gt; mUser = new ArrayList&lt;&gt;();
      private String userID;
      private String Lat;
      private String Lng;
      private Button mRefresh;
      private String Name;
      private String Birthday;
      private String Gender;
      private String Email;
  
      private FirebaseAuth mAuth = FirebaseAuth.getInstance();
      private FirebaseDatabase firebaseDatabase = FirebaseDatabase.getInstance();
      private DatabaseReference DatabaseReference = firebaseDatabase.getReference();
  
      //private DatabaseReference DatabaseReference = firebaseDatabase.getReference().child("Users/");
      //private DatabaseReference CoordenateReference = firebaseDatabase.getReference().child("Coordenate/");
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_search);
  
  
          mListView = findViewById(R.id.listViewSearch);
  
          FirebaseUser user = mAuth.getCurrentUser();
          userID = user.getUid();
          mRefresh = findViewById(R.id.buttonRefresh);
  
  
          mRefresh.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
  
                  DatabaseReference.addValueEventListener(new ValueEventListener() {
                      @Override
                      public void onDataChange(DataSnapshot dataSnapshot) {
                          listClean();
                          FirebaseUser user = mAuth.getCurrentUser();
                          userID = user.getUid();
                          Lat = dataSnapshot.child("Users").child(userID).child("Coordenates/Rute/Lat").getValue(String.class);
                          Lng = dataSnapshot.child("Users").child(userID).child("Coordenates/Rute/Lng").getValue(String.class);
                          DataSnapshot dS = dataSnapshot.child("Coordenate").child(Lat).child(Lng);
  
                          for(DataSnapshot Ds : dS.getChildren()) {
                              Object key = Ds.getKey();
                              String StringKey = String.valueOf(key);
                              getname(StringKey);
                              //mUser.add(getName(StringKey));
                              //mUser.add(Name);
                          }
  
                      }
  
                      @Override
                      public void onCancelled(DatabaseError databaseError) {
                          Toast.makeText(SearchActivity.this,"Error 404",Toast.LENGTH_SHORT).show();
  
                      }
                  });
              }
          });
  
  
  
      }
      private void getname(String ID){
  
  
          final String IDfinal = ID;
          Toast.makeText(SearchActivity.this,ID,Toast.LENGTH_SHORT).show();
          DatabaseReference.addValueEventListener(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
                  Name = dataSnapshot.child("Users").child(IDfinal).child("name").getValue(String.class);
                  Email = dataSnapshot.child("Users").child(IDfinal).child("email").getValue(String.class);
                  Gender = dataSnapshot.child("Users").child(IDfinal).child("gender").getValue(String.class);
                  Birthday = dataSnapshot.child("Users").child(IDfinal).child("data_birth").getValue(String.class);
  
                  list();
  
  
                  Toast.makeText(SearchActivity.this,Name,Toast.LENGTH_SHORT).show();
  
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
                  Toast.makeText(SearchActivity.this,"Error 404",Toast.LENGTH_SHORT).show();
  
              }
          });
      }
  
      private void list(){
          //final ArrayAdapter&lt;String&gt; arrayAdapter = new ArrayAdapter&lt;&gt;(this, android.R.layout.simple_list_item_1, mUser);
          //mListView.setAdapter(new customAdapter(this,new String[]{Name}));
          //mUser.add(Name);
          //arrayAdapter.notifyDataSetChanged();
          setContentView(R.layout.activity_search);
          List&lt;UserInformation&gt; userInformationsList = new ArrayList&lt;&gt;();
          UserInformation userInformation = new UserInformation(Name,Email,Gender,Birthday);
          userInformationsList.add(userInformation);
          customAdapter customAdapterIntent= new customAdapter((ValueEventListener) this,R.layout.userslist,userInformationsList);
          mListView.setAdapter(customAdapterIntent);
      }
  }
  </code></pre>
  
  <p>This is userslist.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
       xmlns:android="http://schemas.android.com/apk/res/android"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="vertical"&gt;
  
      &lt;TextView
          android:id="@+id/textNameList"
          android:textSize="25dp"
          android:textAlignment="textStart"
          android:text="Name"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="start"
          android:layout_margin="10dp"/&gt;
  
      &lt;TextView
          android:id="@+id/textEmailList"
          android:textSize="15dp"
          android:textAlignment="textStart"
          android:text="Age"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="start"
          android:layout_margin="10dp"/&gt;
  
      &lt;TextView
          android:id="@+id/textBirthdayList"
          android:textSize="15dp"
          android:textAlignment="textStart"
          android:text="Birthday"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="start"
          android:layout_margin="10dp"/&gt;
  
      &lt;TextView
          android:id="@+id/textGenderList"
          android:textSize="15dp"
          android:textAlignment="textStart"
          android:text="gender"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:gravity="start"
          android:layout_margin="10dp"/&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>This is Userinformation.java</strong></p>
  
  <pre><code>public class UserInformation {
  
  
      private static String Name;
      private static String Gender;
      private static String Email;
      private static String Birthday;
  
      public UserInformation(String Name,String Gender,String Email,String Birthday){
          this.Birthday=Birthday;
          this.Email=Email;
          this.Gender=Gender;
          this.Name=Name;
      }
  
      public static String getName(){return Name;}
      public static String getEmail(){return Email;}
      public static String getGender(){return Gender;}
      public static String getBirthday(){return Birthday;}
  
  }
  </code></pre>
  
  <p>This is the adapter </p>
  
  <pre><code>public class customAdapter extends ArrayAdapter&lt;UserInformation&gt; {
  
  
  
  
      public customAdapter(ValueEventListener context, int layoutResource, 
      List&lt;UserInformation&gt; userInformationsList) {
          super((Context) context, layoutResource, userInformationsList);
  
      }
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
          View view = convertView;
  
          if (view == null) {
              LayoutInflater layoutInflater = LayoutInflater.from(getContext());
              view = layoutInflater.inflate(R.layout.userslist, null);
          }
  
          UserInformation userInformation = getItem(position);
  
          if (userInformation != null) {
              TextView Name = (TextView) view.findViewById(R.id.textNameList);
              //name.setText(name[position]);
              TextView email = (TextView) view.findViewById(R.id.textEmailList);
              //email.setText(Email[position]);
              TextView gender = (TextView) view.findViewById(R.id.textGenderList);
              //gender.setText(Gender[position]);
              TextView birthday = (TextView) view.findViewById(R.id.textBirthdayList);
              //birthday.setText(Birthday[position]);
  
              if (Name != null) {
                  Name.setText(UserInformation.getName());
              }
              if (email != null) {
                  email.setText(UserInformation.getEmail());
              }
              if (gender != null) {
                  gender.setText(UserInformation.getGender());
              }
              if (birthday != null) {
                  birthday.setText(UserInformation.getBirthday());
              }
          }
  
          return view;
      }
  }
  </code></pre>
  
  <p>This is the error</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.example.enrik.afrodita, PID: 2629
                java.lang.ClassCastException: 
  com.example.enrik.afrodita.SearchActivity cannot be cast to 
  com.google.firebase.database.ValueEventListener
                    at 
  com.example.enrik.afrodita.SearchActivity.list(SearchActivity.java:130)
                    at 
  
  com.example.enrik.afodita.SearchActivity.access$1100(SearchActivity.java:24)
                    at 
  
  com.example.enrik.adita.Searchivity$2.onDataChange(SearchActivity.java:106)
                    at com.google.android.gms.internal.zzdtn.zza(Unknown Source)
                    at com.google.android.gms.internal.zzdvi.zzbur(Unknown Source)
                    at com.google.android.gms.internal.zzdvo.run(Unknown Source)
                    at android.os.Handler.handleCallback(Handler.java:751)
                    at android.os.Handler.dispatchMessage(Handler.java:95)
                    at android.os.Looper.loop(Looper.java:154)
                    at android.app.ActivityThread.main(ActivityThread.java:6119)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
  </code></pre>