Commit 69310e71 authored by 9731301's avatar 9731301

get data in activity andset it in fragment with bundle

parent dd7c31f6
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="$PROJECT_DIR$/my-notepad" vcs="Git" />
</component>
</project>
\ No newline at end of file
package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView;
public class MyAdaptor {
}
package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView;
public class MyNote {
}
package com.example.mynotepad.MenuFeatures.AllNotes.MyNoteRecyclerView;
public interface RecyclerViewOnClickListener {
void onItemClicked(MyNote item);
void onItemLongClick(MyNote item);
}
package com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteRecyclerView;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.example.mynotepad.R;
import java.util.List;
public class MyAdaptor extends RecyclerView.Adapter<MyAdaptor.ViewHolder> {
List<MyNote> notes;
Context context;
public MyAdaptor(List<MyNote> notes, Context context) {
this.notes = notes;
this.context = context;
}
@NonNull
@Override
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.custom_item_row, parent, false);
return new ViewHolder(view);
}
@Override
public void onBindViewHolder(ViewHolder holder, int position) {
holder.titleTV.setText(notes.get(position).getTitle());
holder.descriptionTV.setText(notes.get(position).getDescription());
holder.isAchieved = notes.get(position).isAchieved();
}
@Override
public int getItemCount() {
return notes.size();
}
class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener {
protected TextView titleTV, descriptionTV;
protected boolean isAchieved;
public ViewHolder(View itemView) {
super(itemView);
titleTV = itemView.findViewById(R.id.titleTv);
descriptionTV = itemView.findViewById(R.id.descriptionTv);
isAchieved = false;
}
@Override
public void onClick(View view) {
}
@Override
public boolean onLongClick(View view) {
return false;
}
}
}
package com.example.mynotepad.MenuFeatures.AllNotes.Note.NoteRecyclerView;
public class MyNote {
private String title , description ;
private boolean isAchieved;
public MyNote(String title, String description, boolean isAchieved) {
this.title = title;
this.description = description;
this.isAchieved = isAchieved;
}
public String getTitle() {
return title;
}
public String getDescription() {
return description;
}
public boolean isAchieved() {
return isAchieved;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment