package com.xbsaykat.easy24admin.DailyUsers; import android.content.Intent; import android.graphics.Color; import android.graphics.Typeface; import android.os.Bundle; import android.util.TypedValue; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.ListView; import android.widget.TextView; import android.widget.Toast; import androidx.annotation.Nullable; import androidx.appcompat.app.AppCompatActivity; import com.google.android.material.floatingactionbutton.FloatingActionButton; import com.google.android.material.snackbar.Snackbar; import com.google.firebase.database.DataSnapshot; import com.google.firebase.database.DatabaseError; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase; import com.google.firebase.database.ValueEventListener; import com.xbsaykat.easy24admin.R; import java.util.ArrayList; public class ShowDaily extends AppCompatActivity { String date; DatabaseReference mUsers; ListView List; ArrayList<String> arraylist; ArrayAdapter<String> arrayAdapter; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.checkusers); date = String.valueOf(android.text.format.DateFormat.format("dd-MM-yyyy", new java.util.Date())); mUsers = FirebaseDatabase.getInstance().getReference().child("Today").child(date); List=findViewById(R.id.userlistview); arraylist=new ArrayList<>(); arrayAdapter=new ArrayAdapter<String>(ShowDaily.this,android.R.layout.simple_list_item_1, arraylist){ @Override public View getView(int position, View convertView, ViewGroup parent) { View view = super.getView(position, convertView, parent); TextView tv = (TextView) view.findViewById(android.R.id.text1); // Set the text color of TextView (ListView Item) tv.setTextColor(Color.BLACK); tv.setAllCaps(true); tv.setTypeface(tv.getTypeface(), Typeface.BOLD); tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP,18); // Generate ListView Item using TextView return view; } }; List.setAdapter(arrayAdapter); mUsers.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { for(DataSnapshot snapshot:dataSnapshot.getChildren()){ String ID=snapshot.child("mobile").getValue().toString(); arraylist.add(ID); arrayAdapter.notifyDataSetChanged(); } } @Override public void onCancelled(DatabaseError databaseError) { } }); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Snackbar.make(view, "Today's Users : "+arraylist.size(), Snackbar.LENGTH_LONG) .setAction("Action", null).show(); } }); } }