Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bkg7"
- tools:context=".Aplicativo.TelaTodasPartidas">
- <TextView
- android:id="@+id/txtTodasPartidas"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_alignParentStart="true"
- android:layout_alignParentTop="true"
- android:layout_marginTop="10dp"
- android:gravity="center"
- android:text="Lista das Partidas"
- android:textColor="#FF78FF78"
- android:textAlignment="gravity"
- android:textSize="30sp"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_bias="0.0"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="0.0" />
- <ListView
- android:id="@+id/LVpartidas"
- android:layout_width="0dp"
- android:layout_height="0dp"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintHorizontal_bias="0.0"
- android:textColor="#FF78FF78"
- android:divider="#CEFFFFFF"
- android:dividerHeight="4px"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toBottomOf="@+id/txtTodasPartidas" />
- <ProgressBar
- android:id="@+id/BolinhaLoadTelaTodasPartidas"
- style="?android:attr/progressBarStyle"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_above="@+id/LVpartidas"
- android:layout_centerHorizontal="true"
- android:layout_marginBottom="-254dp"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="0.451" />
- </androidx.constraintlayout.widget.ConstraintLayout>
- --------------------------------------------------------------------------------------------------------------------
- package com.example.appfut03.Aplicativo;
- import androidx.annotation.NonNull;
- import androidx.annotation.Nullable;
- import androidx.appcompat.app.AppCompatActivity;
- import android.graphics.Color;
- import android.os.Bundle;
- import android.text.Html;
- import android.view.LayoutInflater;
- import android.view.View;
- import android.view.ViewGroup;
- import android.widget.ArrayAdapter;
- import android.widget.ListView;
- import android.widget.ProgressBar;
- import android.widget.TextView;
- import android.widget.Toast;
- import com.example.appfut03.Configuracoes.Firebaseconfig;
- import com.example.appfut03.R;
- import com.google.firebase.database.ChildEventListener;
- import com.google.firebase.database.DataSnapshot;
- import com.google.firebase.database.DatabaseError;
- import com.google.firebase.database.DatabaseReference;
- import com.google.firebase.database.Query;
- import com.google.firebase.database.ValueEventListener;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- public class TelaTodasPartidas extends AppCompatActivity {
- private ListView LVpartidas;
- private DatabaseReference fbconfig;
- private ArrayAdapter<String> arrayAdapter;
- private ProgressBar BolinhaLoadTelaTodasPartidas;
- private String partida1;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.tela_todas_partidas);
- LVpartidas = (ListView) findViewById(R.id.LVpartidas);
- BolinhaLoadTelaTodasPartidas = (ProgressBar) findViewById(R.id.BolinhaLoadTelaTodasPartidas);
- final List<String> list = new ArrayList<String>();
- arrayAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, list){
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View view =super.getView(position, convertView, parent);
- TextView textView=(TextView) view.findViewById(android.R.id.text1);
- /*YOUR CHOICE OF COLOR*/
- textView.setText(Html.fromHtml(textView.getText().toString()));
- return view;
- }
- };
- LVpartidas.setAdapter(arrayAdapter);
- fbconfig = Firebaseconfig.getFirebaseConfig();
- fbconfig.child("Partida").addListenerForSingleValueEvent(new ValueEventListener() {
- @Override
- public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
- for (DataSnapshot messageSnapshot : dataSnapshot.getChildren()) {
- partida1 = "<font color=#78ff78>Data: </font><font color=red>"+messageSnapshot.child("dataPartida").getValue().toString()+"<br></font><font color='#78ff78'>Time 1:</font> <font color=red> "+messageSnapshot.child("nomeTime1").getValue().toString()+"</font><font color=#78ff78> Time 2:</font> <font color=red>"+messageSnapshot.child("nomeTime2").getValue().toString()+
- "<br></font><font color=#78ff78> GolsTime1:</font> <font color=red>"+messageSnapshot.child("golsTime1").getValue().toString()+"</font><font color=#78ff78> GolsTime2:</font> <font color=red>"+messageSnapshot.child("golsTime2").getValue().toString()+"</font>" ;
- arrayAdapter.add(partida1);
- arrayAdapter.notifyDataSetChanged();
- BolinhaLoadTelaTodasPartidas.setVisibility(View.INVISIBLE);
- // Toast.makeText(getApplicationContext(), "oi" +partida1+"oi", Toast.LENGTH_LONG).show();
- }
- }
- @Override
- public void onCancelled(@NonNull DatabaseError databaseError) {
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement