Creating a Routes ListView
Now let’s create a new activity to display the routes in a list.
1. Create a new activity called RoutesActivity using the activity wizard. Select Blank Activity as the template for the new Activity
, and set the title as Routes.
2. In the RoutesActivity.java
class, change the class so that it extends ListActivity
rather than Activity
:
public class RoutesActivity extends ListActivity
3. In the res/values/strings.xml
file, add a new resource for the routes
menu:
<string name="menu_routes" >Routes</string>
4. In res/menu/activity_settings.xml
, add a new menu item after the existing XML item node. Specify these attributes: android:id
with a value of @+id/menu_routes ...
Get Learning Android™ Application Programming: A Hands-On Guide to Building Android Applications now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.