How to Make Android Apps 3

How to Make Android Apps Android ListViewsIn this part of the tutorial I’ll cover Android ListViews, ArrayAdapters, Custom Array Adapters, ListAdapter, LayoutInflator, ImageView, and a great deal about terminology that confuses people.

To learn how Android Studio works look here at my Android Studio tutorial. If you missed the first part of this tutorial it is here How to Make Android Apps. All of the code used follows the video below.

If you like videos like this, it helps me if you share it on Google Plus with a click here [googleplusone]

Code From the Video

The first 2 files are for the first easy ListView example. The rest of the files are for the last 2 examples.

Main_Activity.java

activity_main.xml

activity_main.xml

MainActivity.java

MyAdapter.java

row_layout.xml

row_layout_2.xml

Presentation Slides

Click the images below to view them full screen

Android ListView

Android ListView

Android ListView 3

Android ListView 4

14 thoughts on “How to Make Android Apps 3”

  1. Thanks for tutorial. Beginner Question:

    Why did you need to set up

    theImageView.setImageResource(R.drawable.dot);

    Is not in xml already ?

  2. Hi Derek – Awesome tutorials, they’ve been a great help with the app I’m working on. I know it might be a little more advanced, but I was wondering if you’d be able to touch on using AsyncTask to get data from a web service to use for populating a ListView. I’m able to successfully get the data I need from my web service API, but I’m a little stuck on how to connect this back to the ArrayAdapter given the separation between the UI thread and the AsyncTask. I can see in the logs I have my data, but it seems to overall be hanging when going back to the UI and displaying of the data into the ListView. Thanks!

  3. Hi,

    Thanks for the great tutorial.

    After we changed from using android.R.layout.simple_list_item_1 to using our own layout R.layout.row_layout, the program wouldn’t run and I got the error “android.widget.LinearLayout cannot be cast to android.widget.TextView” and I can’t figure out what I did different to you.

    Any thoughts?

    I carried on after that and created the new layout and the adapter and the app worked fine.

    Thanks again for the tutorials.

  4. Hey Derek,

    Thanks for these awesome tutorials, extremely good for beginners like myself.

    I have a question regarding the part where you introduce us to use the customized row design (starting at time 9:46 of video), you told to use LinearLayout with the Text view to create row design. However this didn’t work out for me and I am getting compile time error that id for TextView is not found. I have setup it up correctly but it didn’t work out for me.

    Instead, when I removed the LinearLayout and customised just with TextView, it worked out. Can you please help me understand that why could have that happened?

  5. Basically, I got same error what Paul has mentioned above. I have yet to check with your code, but I am pretty sure that I have done exactly same what you told in video. Android Studio version 0.8.6.

    Since it didn’t explicitly provide option to change the target sdk, all my tutorials app are targeted to Android L.

  6. Hey Derek,

    Great job on the tutorials, I’ve been following you for a while now and I wanna say thanks, you are awesome!
    btw I just want to mention a difference between the code in the video and on your site.
    [MainActiivity.java line 37]

    ListAdapter theAdapter = new ArrayAdapter(this, R.layout.row_layout,
    R.id.textView1, favoriteTVShows);

    And [in your video]

    ListAdapter theAdapter = new MyAdapter(this, favoriteTVShows);

    1. Thank you for the compliment 🙂 I’ll take a look at the code, but normally what I post on my website is perfect. I used to slip up in the videos in the past every once in a while.

  7. Hey Derek!

    Thanks for your work. A try to follow step by step these tutorials and I got an error like Paul (7. September)

    “android.widget.LinearLayout cannot be cast to android.widget.TextView”

    The problem is that your video does not contain the step, when you wrote “R.id.textView1,”.

    Although the correct code on your website contains it.

    ListAdapter theAdapter = new ArrayAdapter(this, R.layout.row_layout, R.id.textView1, favoriteTVShows);

    I hope it can help for others, who have got the same error.

    Thaks again for these tutorials!

    János

Leave a Reply

Your email address will not be published. Required fields are marked *