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));