I have a listview in my xml file called selection.xml.

This is the code for selection.xml.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:layout_width="match_parent" android:layout_height="match_parent">

<ListView
    android:id="@+id/accountsFound"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="25dp" /></LinearLayout>

This is the code for Selection.java

  import android.app.ListActivity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ArrayAdapter;
  import android.widget.ListView;




public class Selection extends ListActivity {


private ListView accountsFound;
private MyArrayAdapter<String> ArrayAdapter;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.selection);

    accountsFound = (ListView)findViewById(R.id.accountsFound);

    final String ProviderName[]= getResources().getStringArray(R.array.ProviderName);
    final String AccountID[]= getResources().getStringArray(R.array.AccountID);
    final String Password[]= getResources().getStringArray(R.array.Password);

    String listAccounts[] = new String[AccountID.length];

    for(int i = 0 ; i < AccountID.length ; i++){
        listAccounts[i] =  ProviderName[i] + " || " +  AccountID[i] + " || " + Password[i];
    }



    MyArrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1, listAccounts );
    accountsFound.setListAdapter(MyArrayAdapter);


}

The error I get is in my Selection.java file in this line of code below. The error I get is the one stated in the title. ("I tried typing it here but it would not print the entire error").

   accountsFound.setListAdapter(MyArrayAdapter);
1

There are 1 answers

0
Ignacio Siel On