Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Austin Houston
Austin Houston
1,617 Points

Note taking app

I am attempting to challenge myself with a note creation app. I have just finished the weather app and think that, with what I have learned so far, I could create a simple note taking app.

My concept: UI would include a listview (or recyclerview?) of notes all derived from a "Note" model. The note model would have getters and setters for its member variables, title and body (the actual note).

When creating a new note, it sets the note objects variables to what was typed in.

When selecting a preexisting note, it gets the variables and puts them in place in editable fashion.

The part that I'm having trouble grasping, before I actually start, is creating a new note object and adding it to the list each time a note is made.

Thanks!

  • A

1 Answer

Harry James
Harry James
14,780 Points

Hey Austin!

Awesome to hear you're ready to make your own app! Before you begin though, I'd like to give you a heads up on a problem you'll have (If you haven't took any of the other courses). That problem is saving your notes!


If you take a look at the Build a Self-Destructing Messaging App course, you'll see how to you can upload pictures to the web and retrieve them back (Though this is easily changeable to use text instead).

Furthermore, you can take a look at the Android Data Persistence course to see how you can save pictures onto the device and retrieve them back from the devices storage (Again, this is easily changeable to use text instead).

You can even use both of these together if you want to make an awesome app!


As for the ListView/RecyclerView, both will suit your needs but a RecyclerView is considered more updated and possibly better for developing. However, if you want to add functionality for selecting (multiple) notes, perhaps a ListView would be the way to go.


As for showing your notes, it's personal preference but, if I was doing this, I would get all of my notes and then store them in an array, like this:

String[] myNotes = // Get notes. You may need to use a foreach loop to get each note and append it to the array.

Then, once all of your notes are stored in an array, I'd recommend using an ArrayAdapter to display all of your notes in your ListView.

In case you're going mad that you don't understand half of the stuff happening here, take a look at the Build a Blog Reader app. It's a bit outdated in that it uses Eclipse but, the same principles apply. Everything I've talked about apart from the ArrayAdapter are used in this course (However, you should be able to understand how to switch adapters pretty easily). You may even just be able to pick this up in the Project Files alone! You could try downloading the final project files and then seeing if you understand the code. The handleBlogResponse() method is where all of the ListView action happens!


Best of luck and, if you need any more help, give me a shout! I'll be here whenever if there's a bit you're stuck on or something you don't understand! :)

Austin Houston
Austin Houston
1,617 Points

Hi Harry,

Thank you so much for the detailed response! I figured I would use an array, but wasn't sure how to make it so that it updates upon creating a new note. Isn't there an add method for strings, or something similar?

This is the page I am referencing for list. https://developer.android.com/training/material/lists-cards.html

I am not sure if I should go with recyclerview or list view. In my understanding, the only difference is that the recyclerview is for more specific data, or something like that. Like the inbox app most likely uses this.

Thanks!

  • A

Edit* Couldn't I use an xml file or JSON file to store the notes? Each note is going to have 3 properties individually.

Harry James
Harry James
14,780 Points

Take a look at 07:12 on this video.

I'm linking you to a video here as, a video tells a thousand words and I'd much prefer you to visually see what Ben is doing here and how he is doing it - it gets in your memory a lot better plus it's easier to understand than a block of text! It is in Eclipse but, the code is no different!

As for the RecyclerView or ListView, I had never heard of a RecyclerView before I saw this post (In fact, I looked it up before I posted an answer). I read a huge article about it and it seems as though the RecyclerView is best suited towards applications where the cards update live on the screen.

Still, I think either way, deciding on a RecyclerView or ListView shouldn't impact your app. Perhaps you may prefer starting off with a ListView (There is a lot of documentation for these) and possibly modifying the code to use a RecyclerView at a later date (When there is more documentation about the Lollipop API's). It's really up to you which one you want to go for and again, it won't affect your apps functionality.

Hope it helps :)