From 50e4682d31caae7b2b7ab734d3de369a5c4e0f25 Mon Sep 17 00:00:00 2001 From: Naiki00 Date: Fri, 8 Jan 2021 23:14:15 +0100 Subject: [PATCH] =?UTF-8?q?Zmiana=20wy=C5=9Bwietlania=20notatki=20na=20wer?= =?UTF-8?q?tykalnie=20z=20horyzontalnego?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/com/example/notatkon/MainActivity.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/example/notatkon/MainActivity.java b/app/src/main/java/com/example/notatkon/MainActivity.java index 34f61c5..d02468f 100644 --- a/app/src/main/java/com/example/notatkon/MainActivity.java +++ b/app/src/main/java/com/example/notatkon/MainActivity.java @@ -9,6 +9,7 @@ import androidx.appcompat.app.AppCompatActivity; import androidx.appcompat.widget.Toolbar; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; +import androidx.recyclerview.widget.StaggeredGridLayoutManager; import com.example.notatkon.note.Note; import com.google.android.material.floatingactionbutton.FloatingActionButton; @@ -43,12 +44,17 @@ public class MainActivity extends AppCompatActivity { //https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView#next-steps RecyclerView recyclerView = (RecyclerView) findViewById(R.id.notes); - //ustaw LayoutManagera + //ustaw LayoutManagera wertykalnie recyclerView.setLayoutManager(new LinearLayoutManager(this)); + //ustaw LayoutManagera horyzontalnie + recyclerView.setLayoutManager(new StaggeredGridLayoutManager(2, StaggeredGridLayoutManager.VERTICAL)); + //wczytaj listę z klasy Note oraz dodaj obiekt jej klasy ArrayList notes = new ArrayList(); notes.add(new Note()); + notes.add(new Note()); + notes.add(new Note()); //połącz Adapter z RecycleView recyclerView.setAdapter(new NoteAdapter(notes, recyclerView));