List view; ArrayAdapter & Modifier Problems

Put problem concerning Views, Layouts and other XML-Resources (like AndroidManifest) here.

List view; ArrayAdapter & Modifier Problems

Postby trontron » Sun Apr 19, 2009 5:50 pm

Hi everybody. I did the 'Hello World' tutorial at Android Developers and everything went smoothly. Then I went on to the 'Hello Views' tutorials, starting with list view. The problem is that I did everything which was said at 'http://developer.android.com/guide/tutorials/views/hello-listview.html'; the tutorial. However once I finished it Eclipse gave me these two error messages:
    ArrayAdapter cannot be resolved to a type Line 57 'Java Problem'
    Illegal modifier for parameter COUNTRIES; only final is permitted Line 12 'Java Problem'
...in the following code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.bluepill.listview;
  2.  
  3. import android.app.ListActivity;
  4. import android.os.Bundle;
  5.  
  6. public class practicewithlistview extends ListActivity {
  7.     /** Called when the activity is first created. */
  8.         @Override
  9.         public void onCreate(Bundle savedInstanceState) {
  10.           super.onCreate(savedInstanceState);
  11.          
  12.                 static final String[] COUNTRIES = new String[] {
  13.                     "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola", "Anguilla", "Antarctica", "Antigua and Barbuda", "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan",
  14. "Bahrain", "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",
  15. "Bosnia and Herzegovina", "Botswana", "Bouvet Island", "Brazil", "British Virgin Islands", "Brunei", "Bulgaria", "Burkina Faso", "Burundi", "Cote d'Ivoire", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands", "Colombia", "Comoros", "Congo", "Cook Islands", "Costa Rica", "Croatia", "Cuba", "Cyprus", "Czech Republic", "Democratic Republic of the Congo", "Denmark", "Djibouti", "Dominica", "Dominican Republic", "East Timor", "Ecuador", "Egypt", "El Salvador", "Equatorial Guinea", "Eritrea", "Estonia", "Ethiopia", "Faeroe Islands", "Falkland Islands", "Fiji", "Finland", "Former Yugoslav Republic of Macedonia", "France", "French Guiana", "French Polynesia", "French Southern Territories", "Gabon", "Georgia", "Germany", "Ghana", "Gibraltar", "Greece", "Greenland", "Grenada", "Guadeloupe", "Guam", "Guatemala", "Guinea", "Guinea-Bissau", "Guyana", "Haiti", "Heard Island and McDonald Islands", "Honduras", "Hong Kong", "Hungary", "Iceland", "India", "Indonesia", "Iran", "Iraq", "Ireland", "Israel", "Italy", "Jamaica", "Japan", "Jordan", "Kazakhstan", "Kenya", "Kiribati", "Kuwait", "Kyrgyzstan", "Laos", "Latvia", "Lebanon", "Lesotho", "Liberia", "Libya", "Liechtenstein", "Lithuania", "Luxembourg", "Macau", "Madagascar", "Malawi", "Malaysia", "Maldives", "Mali", "Malta", "Marshall Islands", "Martinique", "Mauritania", "Mauritius", "Mayotte", "Mexico", "Micronesia", "Moldova", "Monaco", "Mongolia", "Montserrat", "Morocco", "Mozambique", "Myanmar", "Namibia", "Nauru", "Nepal", "Netherlands", "Netherlands Antilles", "New Caledonia", "New Zealand", "Nicaragua", "Niger", "Nigeria", "Niue", "Norfolk Island", "North Korea", "Northern Marianas", "Norway", "Oman", "Pakistan", "Palau", "Panama", "Papua New Guinea", "Paraguay", "Peru", "Philippines", "Pitcairn Islands", "Poland", "Portugal", "Puerto Rico", "Qatar", "Reunion", "Romania", "Russia", "Rwanda", "Sqo Tome and Principe", "Saint Helena", "Saint Kitts and Nevis", "Saint Lucia", "Saint Pierre and Miquelon", "Saint Vincent and the Grenadines", "Samoa", "San Marino", "Saudi Arabia", "Senegal", "Seychelles", "Sierra Leone", "Singapore", "Slovakia", "Slovenia", "Solomon Islands", "Somalia", "South Africa", "South Georgia and the South Sandwich Islands", "South Korea", "Spain", "Sri Lanka", "Sudan", "Suriname", "Svalbard and Jan Mayen", "Swaziland", "Sweden", "Switzerland", "Syria", "Taiwan", "Tajikistan", "Tanzania", "Thailand", "The Bahamas", "The Gambia", "Togo", "Tokelau", "Tonga", "Trinidad and Tobago", "Tunisia", "Turkey", "Turkmenistan", "Turks and Caicos Islands", "Tuvalu", "Virgin Islands", "Uganda", "Ukraine", "United Arab Emirates", "United Kingdom", "United States", "United States Minor Outlying Islands", "Uruguay", "Uzbekistan", "Vanuatu", "Vatican City", "Venezuela", "Vietnam", "Wallis and Futuna", "Western Sahara", "Yemen", "Yugoslavia", "Zambia", "Zimbabwe"
  16.                   };
  17.  
  18.          
  19.           setListAdapter(new ArrayAdapter<String>(this,
  20.                   android.R.layout.simple_list_item_1, COUNTRIES));
  21.           getListView().setTextFilterEnabled(true);
  22.         }
  23.  
  24. }
Parsed in 0.061 seconds, using GeSHi 1.0.8.4

Please note that the only file I edited was the one which is created a long with a new project. I understand what the errors mean but I don't really know what to do to fix them without losing functionality. I was hoping for some insight in to the problem. Sorry if the problem is something stupid because I just started developing in Java.

Thank you for you help!

Edit: I managed to fix it myself. I noticed there was no import.android.widget.ArrayAdapter line and I simply removed 'static' from 'static final String []'
User avatar
trontron
Freshman
Freshman
 
Posts: 4
Joined: Sun Apr 19, 2009 5:14 pm

Top

Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: No registered users and 16 guests