Advertisement
detonax

Tela Lista todas as partidas

Mar 30th, 2019
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.26 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. xmlns:app="http://schemas.android.com/apk/res-auto"
  4. xmlns:tools="http://schemas.android.com/tools"
  5.  
  6. android:layout_width="match_parent"
  7. android:layout_height="match_parent"
  8. android:background="@drawable/bkg7"
  9. tools:context=".Aplicativo.TelaTodasPartidas">
  10.  
  11.  
  12. <TextView
  13. android:id="@+id/txtTodasPartidas"
  14. android:layout_width="match_parent"
  15. android:layout_height="wrap_content"
  16. android:layout_alignParentStart="true"
  17. android:layout_alignParentTop="true"
  18. android:layout_marginTop="10dp"
  19. android:gravity="center"
  20. android:text="Lista das Partidas"
  21. android:textColor="#FF78FF78"
  22. android:textAlignment="gravity"
  23. android:textSize="30sp"
  24. app:layout_constraintBottom_toBottomOf="parent"
  25. app:layout_constraintEnd_toEndOf="parent"
  26. app:layout_constraintHorizontal_bias="0.0"
  27. app:layout_constraintStart_toStartOf="parent"
  28. app:layout_constraintTop_toTopOf="parent"
  29. app:layout_constraintVertical_bias="0.0" />
  30.  
  31.  
  32. <ListView
  33. android:id="@+id/LVpartidas"
  34. android:layout_width="0dp"
  35. android:layout_height="0dp"
  36. app:layout_constraintBottom_toBottomOf="parent"
  37. app:layout_constraintEnd_toEndOf="parent"
  38. app:layout_constraintHorizontal_bias="0.0"
  39. android:textColor="#FF78FF78"
  40. android:divider="#CEFFFFFF"
  41. android:dividerHeight="4px"
  42. app:layout_constraintStart_toStartOf="parent"
  43. app:layout_constraintTop_toBottomOf="@+id/txtTodasPartidas" />
  44.  
  45. <ProgressBar
  46. android:id="@+id/BolinhaLoadTelaTodasPartidas"
  47. style="?android:attr/progressBarStyle"
  48. android:layout_width="wrap_content"
  49. android:layout_height="wrap_content"
  50. android:layout_above="@+id/LVpartidas"
  51. android:layout_centerHorizontal="true"
  52. android:layout_marginBottom="-254dp"
  53. app:layout_constraintBottom_toBottomOf="parent"
  54. app:layout_constraintEnd_toEndOf="parent"
  55. app:layout_constraintStart_toStartOf="parent"
  56. app:layout_constraintTop_toTopOf="parent"
  57. app:layout_constraintVertical_bias="0.451" />
  58.  
  59.  
  60. </androidx.constraintlayout.widget.ConstraintLayout>
  61.  
  62.  
  63.  
  64.  
  65.  
  66. --------------------------------------------------------------------------------------------------------------------
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. package com.example.appfut03.Aplicativo;
  75.  
  76. import androidx.annotation.NonNull;
  77. import androidx.annotation.Nullable;
  78. import androidx.appcompat.app.AppCompatActivity;
  79.  
  80. import android.graphics.Color;
  81. import android.os.Bundle;
  82. import android.text.Html;
  83. import android.view.LayoutInflater;
  84. import android.view.View;
  85. import android.view.ViewGroup;
  86. import android.widget.ArrayAdapter;
  87. import android.widget.ListView;
  88. import android.widget.ProgressBar;
  89. import android.widget.TextView;
  90. import android.widget.Toast;
  91.  
  92. import com.example.appfut03.Configuracoes.Firebaseconfig;
  93. import com.example.appfut03.R;
  94. import com.google.firebase.database.ChildEventListener;
  95. import com.google.firebase.database.DataSnapshot;
  96. import com.google.firebase.database.DatabaseError;
  97. import com.google.firebase.database.DatabaseReference;
  98. import com.google.firebase.database.Query;
  99. import com.google.firebase.database.ValueEventListener;
  100.  
  101. import java.util.ArrayList;
  102. import java.util.HashMap;
  103. import java.util.List;
  104.  
  105. public class TelaTodasPartidas extends AppCompatActivity {
  106.  
  107. private ListView LVpartidas;
  108. private DatabaseReference fbconfig;
  109. private ArrayAdapter<String> arrayAdapter;
  110. private ProgressBar BolinhaLoadTelaTodasPartidas;
  111. private String partida1;
  112.  
  113. @Override
  114. protected void onCreate(Bundle savedInstanceState) {
  115. super.onCreate(savedInstanceState);
  116. setContentView(R.layout.tela_todas_partidas);
  117.  
  118. LVpartidas = (ListView) findViewById(R.id.LVpartidas);
  119. BolinhaLoadTelaTodasPartidas = (ProgressBar) findViewById(R.id.BolinhaLoadTelaTodasPartidas);
  120. final List<String> list = new ArrayList<String>();
  121. arrayAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, list){
  122.  
  123. @Override
  124. public View getView(int position, View convertView, ViewGroup parent) {
  125. View view =super.getView(position, convertView, parent);
  126.  
  127. TextView textView=(TextView) view.findViewById(android.R.id.text1);
  128.  
  129. /*YOUR CHOICE OF COLOR*/
  130. textView.setText(Html.fromHtml(textView.getText().toString()));
  131.  
  132. return view;
  133. }
  134.  
  135. };
  136.  
  137.  
  138. LVpartidas.setAdapter(arrayAdapter);
  139.  
  140. fbconfig = Firebaseconfig.getFirebaseConfig();
  141. fbconfig.child("Partida").addListenerForSingleValueEvent(new ValueEventListener() {
  142. @Override
  143. public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
  144. for (DataSnapshot messageSnapshot : dataSnapshot.getChildren()) {
  145. 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()+
  146. "<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>" ;
  147.  
  148.  
  149. arrayAdapter.add(partida1);
  150. arrayAdapter.notifyDataSetChanged();
  151. BolinhaLoadTelaTodasPartidas.setVisibility(View.INVISIBLE);
  152. // Toast.makeText(getApplicationContext(), "oi" +partida1+"oi", Toast.LENGTH_LONG).show();
  153. }
  154. }
  155.  
  156. @Override
  157. public void onCancelled(@NonNull DatabaseError databaseError) {
  158.  
  159. }
  160. });
  161.  
  162.  
  163. }
  164.  
  165.  
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement