Android Development 22

Android Development 22In this tutorial I will connect the ListFragment to the Census App, so that when you click on an item we’ll be able update the Contacts. This tutorial began at part 18, so if you missed that video start there.

All the Contacts are updated and we also cover how to store and pass contact IDs between activities. We also streamline the code by separating duplicate code out into another class and much more.

If you like videos like this, it helps to tell Google+ with a click here [googleplusone]

Code From the Video

CensusApp.java

ContactListActivity.java

FragmentActivityBuilder.java

FragmentContactList.java

ContactFragment.java

list_item_contact.xml

23 thoughts on “Android Development 22”

  1. Hello Derek, the tutorial series is excellent!

    Im not sure where to post requests so here it goes:

    I would like to make Reference apps based on html documents; for example I have a homebrew RPG website with basic html links to rules, and spell lists which link to hundreds of spells.

    Is there an easy way to integrate all the html content with minimal retyping/reformating etc? (like copying the html pages in a project folder and having an app shell to access and navigate with options like home, back, next, bookmark?)
    Having the content integrated in the app, so that you can get it from a Play Store and consult/read it offline.

    If thats not possible, a tutorial for a reader app with internal links between pages would be great.

    best regards

    Richard

    1. Hello Richard,

      I have a couple of tutorials on parsing xml and json in this tutorial series. You could also pull in the page and then pull out the information you need with regular expressions. You may also find this useful TagSoup.

      I’ll do my best to make a tutorial on how to parse regular html in Android.

      1. Hi Derek, will you be able to provide code to retrieve contact images (either from gallery or camera) and store them as part of the contact?

  2. Hey Derek,

    I really love your tutorials! Helped me a lot to develope my own application 🙂

    Is it possible to make a tutorial video about the Navigation Drawer and ActionBars?

    Best regards!

    Marcel

  3. Hello Derek,
    Is it possible for you to upload the tutorials in some other video sharing website in addition to youtube. I’m from a country where unfortunately, youtube is banned 🙁 I will really appreciate if you can share your videos in facebook or other sharing sites.

    Thanks

    1. Hello,

      I’d be happy to upload them, but I don’t know where to upload. Youku for example wouldn’t allow me to upload all the videos for some reason. Some where ok and other were not.

      If you give me a list of sites you can use I’ll see what I can do.

      Thank you
      Derek

      1. Thanks Derek for replying. Though I myself have never done much video sharing. But I think you can create a facebook page and upload videos there. In addition couple of other video sharing sites that I’m aware of are
        a) metacafe.com
        b) dailymotion.com

        Thanks
        Asalam

        1. Hi Asalam,

          I have a few problems using these sites, but 1 of them may work.

          1. Facebook randomly won’t allow me to upload certain videos. That is why I no longer use Facebook
          2. Metacafe only allows videos to be 10 minutes or less. They have also blocked some of my videos
          3. Dailymotion might work. I’ll give it a try

          Thanks
          Derek

      2. Hi Derek,
        My previous comment has been in moderation. May be because i used website addresses. Anyways, my suggestion for video sharing were
        a) You can use facebook page and share videos
        b) metacafe and dailymotion work similar to youtube and can be used for video sharing.

        Thanks

        1. Sorry it took so long to respond. I have to approve comments on my own because my site gets attacked all of the time. It looks like DailyMotion might work. I check it out.

  4. Hey Derek! Thanks for your very helpful set of tutorials, they are really clear and well prepared. 🙂

    However, I’m wondering why in the android, when people use fragments, it seems that you (and everyone else) is using setArguments/getArguments to pass data around, where in your factory method (newContactFragment) you could have used a directement assignement: contactFragment.contactId = passedData.

    Is it something linked to fragment life management? (but you are only reusing the argument in onCreate(), so only at creation time, not after a pause/resume).
    Thanks for shedding some lights on this!

    1. It is probably because we all learned from the same tutorials and that just stuck. I do my best to keep up on deprecated functions with Android. Thankfully they aren’t fully deprecating code. Since I make apps all of the time I have less and less time to look back at improved new options. I hope that makes sense.

  5. A bug in class ContactFragment, function onCreateView
    Step to reproduce
    1 On contact list, click the first person
    2 On contact page, do nothing just hit back button
    3 On the contact list, the name disappear

    The reason is these code
    contactNameEditText.setText(contact.getName());
    contactStreetEditText.setText(contact.getStreetAddress());
    contactCityEditText.setText(contact.getCity());
    contactPhoneEditText.setText(contact.getPhoneNumber());
    is after your set the listener, these code will invoke the listener as well.
    The bad news is the focus in always on the name text field. so the name
    field will be overwritten by phoneNumber.
    You can log the contact before you return the view.
    So these setText codes should be put before set the listener.

    1. Thank you for posting the error. One problem with posting videos fast is that I don’t have time to optimize the code. I’ll eventually start making complete apps that are optimized.

  6. Hey Derek,
    Great tutorials! My question to you and everyone that reading this is, dont I need something that make my onListItemClick to work? I have made a copy of your application but with products instead of contacts and the only thing I do not get to work is when I press in the list the details should show. Only thing I get when I press in my textview is “TextView does not support text selection. Action mode cancelled.” I have tried to add and mix this stuff in the xml file:
    android:enabled=”false”
    android:clickable=”true”
    android:focusable=”false”
    android:focusableInTouchMode=”false”
    but non of them changed anything more than I can’t modify in the list (which was good but in the end did not help me). Please could someone help me with my problem?

  7. Hi Derek,

    I have a question, on my code I get a java.lang.NullPointerException everytime I click one of the contacts, which seems to be caused by the listeners on ContactFragment. I also copied your code entirely (maintaning the package name to match mine) and still get the same error

    Since I’m so new to this, I would appreciate if you could help me figure out what seems to be the problem. I commented all the setName() from ContactFragment.java and then the contact info opens (with all fields empty), and as soon as I put a letter in one of the EditText the app crashes again with the null pointer exception.

    The error in logcat is in here: http://pastebin.com/NJ2hYgXk

    Thanks in advance,

    José

Leave a Reply

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