diff --git a/.idea/misc.xml b/.idea/misc.xml index 99202cc..c0f68ed 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -25,7 +25,7 @@ - + diff --git a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/fragment/ContatosFragment.java b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/fragment/ContatosFragment.java index e70e177..7fb12a0 100644 --- a/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/fragment/ContatosFragment.java +++ b/app/src/main/java/br/com/whatsappandroid/cursoandroid/whatsapp2/fragment/ContatosFragment.java @@ -7,14 +7,22 @@ import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.widget.ArrayAdapter; +import android.widget.ListView; + +import java.util.ArrayList; import br.com.whatsappandroid.cursoandroid.whatsapp2.R; +import br.com.whatsappandroid.cursoandroid.whatsapp2.model.Contato; /** * A simple {@link Fragment} subclass. */ public class ContatosFragment extends Fragment { + private ListView listView; + private ArrayAdapter adapter; + private ArrayList contatos; public ContatosFragment() { // Required empty public constructor @@ -24,8 +32,25 @@ public ContatosFragment() { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + + //Instânciar objetos + contatos = new ArrayList<>(); + contatos.add("Mariana Silva"); + contatos.add("Leticia Almeida"); + contatos.add("José Renato"); + // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_contatos, container, false); + View view = inflater.inflate(R.layout.fragment_contatos, container, false); + + listView = view.findViewById(R.id.lv_contatos); + adapter = new ArrayAdapter( + getActivity(), + R.layout.lista_contato, + contatos + ); + listView.setAdapter(adapter); + + return view; } } diff --git a/app/src/main/res/layout/fragment_contatos.xml b/app/src/main/res/layout/fragment_contatos.xml index 394ffcc..9412463 100644 --- a/app/src/main/res/layout/fragment_contatos.xml +++ b/app/src/main/res/layout/fragment_contatos.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:background="@android:color/darker_gray" tools:context=".fragment.ContatosFragment"> @@ -12,19 +13,16 @@ android:layout_width="match_parent" android:layout_height="match_parent"> - + \ No newline at end of file