Solved

ListActivity

Posted on 2012-04-06
2
480 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

If your app took Google’s lash recently, here are the 5 most likely reasons.
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…

623 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