Solved

ListActivity

Posted on 2012-04-06
2
477 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I tunes, androids and windows 10 3 51
mySMS seems stuck after install 7 52
Building a mobile voice application 8 118
Samsung Tablet no Internet but does connect to WiFi 7 52
In this article we will discuss all things related to StageFright bug, the most vulnerable bug of android devices.
If you use the Google Now Launcher, as an aftermarket add on, have a Samsung Note 5 and are worried about power consumption be wary of using the ultra power saving mode.  Here is what happened to me when I made the mistake of trying this out...
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.

751 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