Utworzenie obiektu klasy RecyclerView, utworzenie obiektu Adaptera i przypisane danych
This commit is contained in:
parent
5eec31c7ed
commit
43ba322849
@ -1,17 +1,22 @@
|
|||||||
package com.example.notatkon;
|
package com.example.notatkon;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.view.Menu;
|
||||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
import android.view.MenuItem;
|
||||||
import com.google.android.material.snackbar.Snackbar;
|
import android.view.View;
|
||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity;
|
import androidx.appcompat.app.AppCompatActivity;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
import androidx.appcompat.widget.Toolbar;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import android.view.View;
|
import com.example.notatkon.note.Note;
|
||||||
|
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||||
|
import com.google.android.material.snackbar.Snackbar;
|
||||||
|
|
||||||
import android.view.Menu;
|
import com.example.notatkon.note.NoteAdapter;
|
||||||
import android.view.MenuItem;
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
|
|
||||||
@ -19,9 +24,11 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_main);
|
setContentView(R.layout.activity_main);
|
||||||
|
|
||||||
|
/*
|
||||||
Toolbar toolbar = findViewById(R.id.toolbar);
|
Toolbar toolbar = findViewById(R.id.toolbar);
|
||||||
setSupportActionBar(toolbar);
|
setSupportActionBar(toolbar);
|
||||||
|
*/
|
||||||
FloatingActionButton fab = findViewById(R.id.fab);
|
FloatingActionButton fab = findViewById(R.id.fab);
|
||||||
fab.setOnClickListener(new View.OnClickListener() {
|
fab.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -30,8 +37,26 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
.setAction("Action", null).show();
|
.setAction("Action", null).show();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//metody
|
||||||
|
//https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView#next-steps
|
||||||
|
|
||||||
|
RecyclerView recyclerView = (RecyclerView) findViewById(R.id.notes);
|
||||||
|
//ustaw LayoutManagera
|
||||||
|
recyclerView.setLayoutManager(new LinearLayoutManager(this));
|
||||||
|
|
||||||
|
//wczytaj listę z klasy Note oraz dodaj obiekt jej klasy
|
||||||
|
ArrayList<Note> notes = new ArrayList<Note>();
|
||||||
|
notes.add(new Note());
|
||||||
|
|
||||||
|
//połącz Adapter z RecycleView
|
||||||
|
recyclerView.setAdapter(new NoteAdapter(notes, recyclerView));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
@Override
|
@Override
|
||||||
public boolean onCreateOptionsMenu(Menu menu) {
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
// Inflate the menu; this adds items to the action bar if it is present.
|
// Inflate the menu; this adds items to the action bar if it is present.
|
||||||
@ -53,4 +78,6 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
return super.onOptionsItemSelected(item);
|
return super.onOptionsItemSelected(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user