SHARE
TWEET

Untitled

a guest Nov 9th, 2019 90 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.example.androidnotesapplication.Adapters;
  2.  
  3. import android.content.Context;
  4. import android.view.LayoutInflater;
  5. import android.view.View;
  6. import android.view.ViewGroup;
  7. import android.widget.ArrayAdapter;
  8. import android.widget.TextView;
  9.  
  10. import com.example.androidnotesapplication.R;
  11. import com.example.androidnotesapplication.Models.Note;
  12. import com.example.androidnotesapplication.Utilities.General;
  13.  
  14. import java.util.ArrayList;
  15.  
  16. public class NotesAdapter extends ArrayAdapter<Note> {
  17.  
  18.     public NotesAdapter(Context context, ArrayList<Note> notes) {
  19.         super(context, 0, notes);
  20.     }
  21.  
  22.     @Override
  23.     public View getView(int position, View convertView, ViewGroup parent) {
  24.         Note note = getItem(position);
  25.  
  26.         if (convertView == null) {
  27.             convertView = LayoutInflater.from(getContext()).inflate(R.layout.note_layout, parent, false);
  28.         }
  29.  
  30.         TextView text = convertView.findViewById(R.id.note_text);
  31.         TextView dateModified = convertView.findViewById(R.id.date_modified);
  32.  
  33.         text.setText(note.getText());
  34.         dateModified.setText("Last modified: " + General.stringDateFromLong(note.getDateModified()));
  35.  
  36.         return convertView;
  37.     }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top