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 ''; 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' the following code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package com.bluepill.listview;
  3. import;
  4. import android.os.Bundle;
  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);
  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.                   };
  19.           setListAdapter(new ArrayAdapter<String>(this,
  20.                   android.R.layout.simple_list_item_1, COUNTRIES));
  21.           getListView().setTextFilterEnabled(true);
  22.         }
  24. }
Parsed in 0.060 seconds, using GeSHi

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 line and I simply removed 'static' from 'static final String []'
User avatar
Posts: 4
Joined: Sun Apr 19, 2009 5:14 pm


Return to View, Layout & Resource Problems

Who is online

Users browsing this forum: Google Feedfetcher and 5 guests