DONN FELKER

Lessons Learned From the Software Industry

  • Home
  • About
  • Development Training
  • Fragmented Podcast
  • Learn to Work for Yourself
  • Contact

Connect

  • GitHub
  • Google+
  • Instagram
  • LinkedIn
  • RSS
  • Twitter

Powered by Genesis

Android App Dev for Dummies & Motorola Droids

December 26, 2010 by Donn Felker Leave a Comment

Recently, a kind reader by the name of Lee emailed me about an issue he had with not being able to connect his device to the computer for debugging purposes. He followed all of the examples and notes in the book and still could not get it to work. So, if you cannot get your Motorola Droid phone to connect to Eclipse, follow these instructions:
  • Download the driver (note, there may be a newer version available in the future and you may want to try that one) Motorola 4.7.1 Driver with MotoConnect*
  • From this location: http://www.motorola.com/consumers/v/index.jsp?vgnextoid=bda09ec8009a0210VgnVCM1000008806b00aRCRD
Sorry for the additional bit of work, but thanks to Lee we have a quick solution.

Filed Under: Book, Mobile Tagged With: Android

Beyond Dummies: Improving Performance on the ListView

December 7, 2010 by Donn Felker 3 Comments

In my Android Application Development for Dummies book, I cover working with list views. The example I provided works excellent and you can follow along in the book to implement the given example. This post is about how you can improve the performance of the ListView and its items.

When rendering a list view in the book, I override the getView method on the ListActivity. At that point I inflate the view from the resources. The code snippet looks like this:


view = mInflater.inflate(R.layout.row, parent, false);

This happens each time a view is created on the list view. Unforatunately, this is quite slow on lists with tons of items (say, for example – 10,000 items).The reason this is slow is because each time the list view has to go to a new item, it must be inflated from XML manually, parsed, and then objects have to be instantiated and rendered. Doing this 10,000 times is very very slow.

To improve the speed in which the list view renders the items the list view only builds the views which are on the screen. That means if you have 10,000 items you want to put in the listview, and only 10 are on the screen at once, then only 10 views are being shown. As the user flings the screen and list items are moved out of view the ListView will take that view and recycle it, giving it back to getView(…) as the “convertView” parameter. This view is already hydrated and inflated. Therefore, you can improve the performance of your list view by simply changing the above code to this:


if(convertView == null) {

view = mInflater.inflate(R.layout.row, parent, false);

} else {

view = convertView;

}

// Or you can just always use "convertView" and if its null, inflate it the first time. If thats the case you'd only need

// to use the 'if' part of the statement above

You will now be using a recycled view and the android view system will not have to work overtime inflating views over and over and over.

To really polish up your ListActivity skills, watch the “The world of ListView” Google IO Video by Romain Guy and Adam Powell

Filed Under: Book Tagged With: Android

« Previous Page
Donn Felker Google Android GDE Fragmented - An Android Developer Podcast

Projects / Apps

Caster.IO
Fragmented Podcast
American Express Android
Aaptiv
AndroidJobs.IO
Groupon
MyFitnessPal
Poynt

Books

  • Android Developer Tools
  • Android App Dev For Dummies V2 (V1)
  • Android Tablet App Dev for Dummies

Categories

  • Book
  • Business
  • Development
  • Health
  • Marketing
  • Misc
  • Mobile
  • Screencasts
  • Uncategorized