Last active
October 17, 2018 21:29
-
-
Save fernandolopes/8f962a5443b678f17bd8f5e90f678fc9 to your computer and use it in GitHub Desktop.
MainActivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package com.example.fernando.myapplication; | |
| import android.content.Context; | |
| import android.database.DataSetObserver; | |
| import android.support.v7.app.AppCompatActivity; | |
| import android.os.Bundle; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.view.inputmethod.InputMethodManager; | |
| import android.widget.AdapterView; | |
| import android.widget.Button; | |
| import android.widget.EditText; | |
| import android.widget.ListAdapter; | |
| import android.widget.ListView; | |
| import com.example.fernando.myapplication.models.Partida; | |
| import com.example.fernando.myapplication.models.Valor; | |
| import java.util.ArrayList; | |
| import java.util.List; | |
| public class MainActivity extends AppCompatActivity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.lista); | |
| ListView lista = (ListView) findViewById(R.id.lista_data); | |
| List<Partida> data = new ArrayList<>(); | |
| Partida p = GetPartida(1L, "Fortaleza", "Ceará", "17:00"); | |
| Partida p1 = GetPartida(2L, "São Paulo", "Palmeiras", "22:00"); | |
| Partida p2 = GetPartida(3L, "Gremio", "Internacional", "20:00"); | |
| Partida p3 = GetPartida(4L, "Ferroviário", "Pacatuba", "16:00"); | |
| data.add(p); | |
| data.add(p1); | |
| data.add(p2); | |
| data.add(p3); | |
| MyAdapter adapter = new MyAdapter(this, data); | |
| lista.setAdapter(adapter); | |
| lista.deferNotifyDataSetChanged(); | |
| } | |
| private Partida GetPartida(Long id, String time1, String time2, String horario){ | |
| Partida p = new Partida(); | |
| p.setId(id); | |
| p.setTime1(time1); | |
| p.setTime2(time2); | |
| p.setHorario(horario); | |
| Valor[] dados = new Valor[12]; | |
| for(int i = 0; i <= 11; i++) { | |
| Valor v = new Valor(); | |
| float valor = (float)(0 + Math.random() * (12.829191 - 0)); | |
| v.setValor(Float.parseFloat(String.format("%.2f",valor).replace(",", "."))); | |
| dados[i] = v; | |
| } | |
| p.setValores(dados); | |
| return p; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment