dodano onCreate i intencję tworzenia nowej notatki

This commit is contained in:
Naiki00 2021-02-11 02:17:56 +01:00
parent 9f240677b6
commit fd419761f4

View File

@ -1,5 +1,6 @@
package com.example.notatkon; package com.example.notatkon;
import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
@ -21,24 +22,35 @@ import java.util.ArrayList;
public class MainActivity extends AppCompatActivity { public class MainActivity extends AppCompatActivity {
private static final int REQUEST_CODE_NEW_NOTE = 1;
@Override @Override
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);
Intent intent = new Intent(this,
CreateNote.class);
Toolbar toolbar = findViewById(R.id.toolbar); //Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar); //setSupportActionBar(toolbar);
/*
https://developer.android.com/guide/components/activities/activity-lifecycle
https://developer.android.com/training/basics/intents/result
*/
FloatingActionButton fab = findViewById(R.id.fab); FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() { fab.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View view) { public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) startActivityForResult(intent, REQUEST_CODE_NEW_NOTE);
.setAction("Action", null).show();
//Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show();
} }
}); });
/* -- Pierwsza wersja apki --
//metody //metody
//https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView#next-steps //https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView#next-steps
@ -58,7 +70,7 @@ public class MainActivity extends AppCompatActivity {
//połącz Adapter z RecycleView //połącz Adapter z RecycleView
recyclerView.setAdapter(new NoteAdapter(notes, recyclerView)); recyclerView.setAdapter(new NoteAdapter(notes, recyclerView));
}
/* /*
@ -85,4 +97,5 @@ public class MainActivity extends AppCompatActivity {
} }
*/ */
}
} }