Solved

ListActivity

Posted on 2012-04-06
2
465 Views
Last Modified: 2012-04-09
Please see the attahed file. When I extend Activity everything works fine. When I extend ListActivity the application crashes. Why is that? Am I not implementing something?

Basically trying to implement a screen with a few navigation buttons, and in the middle a ListView. Need help implementing.
ListActivity.txt
0
Comment
Question by:InfoTechEE
2 Comments
 
LVL 8

Accepted Solution

by:
Santhana earned 500 total points
ID: 37818561
Hi  InfoTechEE,

Refer this from android docs.
http://developer.android.com/reference/android/app/ListActivity.html

You must have the list view with the id "@android:id/list" in your layout file "saved"

     <ListView android:id="@android:id/list"              
     android:layout_width="match_parent"              
     android:layout_height="match_parent"/>

Get this list from the activity like this

listDisplayFiles = (ListView) findViewById(android.R.id.list);

Other wise it will through the error at run time...
0
 
LVL 7

Expert Comment

by:tampnic
ID: 37821378
If your writing code within the list activity its easier and faster to get the ListView associated with the activity by using the getListView() function (inherited from the base class ListActivity). This function returns the list reference directly from the base class without having to do a (sometimes costly) findViewById() call.

Cheers,
  Chris
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is a continuation of Part-1 as evident from the title. Please visit this page (http://www.experts-exchange.com/articles/18706/Backing-up-personal-data-on-your-Android-device-Part-1.html) to read the earlier Part -1. If y…
The case of the missing phone talks about the way a small electronic gadget (the mobile phone) has penetrated into our lives and has made us addicted to it.
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question