title: How can I convert ArrayList to ListView?
body: <p>I'm tring to get a array from PHP page and show it in ListView.</p>
  
  <p>I tried to put it in ListAdapter but this problem appears:</p>
  
  <blockquote>
    <p>01-21 09:13:44.223: E/AndroidRuntime(1974): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.e_music/com.example.e_music.ViewArtists}: java.lang.ClassCastException: java.util.ArrayList cannot be cast to android.widget.ListAdapter</p>
  </blockquote>
  
  <p><strong>Android Code:</strong></p>
  
  <pre><code>@SuppressLint("NewApi") public class ViewArtists extends ListActivity{
      // url to get all products list
      private static String urlArtists= "http://mwssong.esy.es/android/ViewArtists.php";
  
      // JSON Node names
      public static final String TAG_SUCCESS = "success";
      public static final String TAG_Artist = "Artists";
      public static final String TAG_id = "id";
      public static final String TAG_FName = "FName";
  
     ArrayList&lt;Artist&gt; getArtists =new ArrayList&lt;Artist&gt;();  
  
     class Artist {
  
         public String id;
         public String FName;
         public String LName;
         public String Gender;
         public String Country;      
     }
  
     static ArrayList&lt;String&gt; ResultRow;
     @TargetApi(Build.VERSION_CODES.GINGERBREAD) @SuppressLint("NewApi") protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.viewartists);
  
          String result ="";
  
          try{
              StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
  
              StrictMode.setThreadPolicy(policy); 
  
              HttpClient httpClient = new DefaultHttpClient();
              HttpPost httpPost = new HttpPost("http://mwssong.esy.es/android/ViewArtists.php");
              HttpResponse httpResponse = httpClient.execute(httpPost);
              HttpEntity httpEntity = httpResponse.getEntity();
              InputStream is = httpEntity.getContent();
  
              try {
  
                  BufferedReader reader =new BufferedReader(new InputStreamReader(is,"iso-8859-1" ),8);
                  StringBuilder sb = new StringBuilder();
                  String line = null;
                  while ((line = reader.readLine()) != null) {
                      sb.append(line + "\n");
                  }
                  is.close();
                  result=sb.toString();
              }catch (Exception e){
                  Log.e("log_tag", "error1 " + e.toString());
  
              }
  
          }catch (Exception e){
              Log.e("log_tag","error2 " +  e.toString());
  
          }
  
          try{
              JSONArray jArray= new JSONArray(result);
              for(int i=0; i&lt;jArray.length();i++){
                  JSONObject json_data =jArray.getJSONObject(i);
                  //Create new Artist:
                  Artist ArtistRow= new Artist();
                  //Get attributes:
                  ArtistRow.id=json_data.getString("id");
                  ArtistRow.FName=json_data.getString("FName");
                  ArtistRow.LName=json_data.getString("LName");
                  ArtistRow.Gender=json_data.getString("Gender");
                  ArtistRow.Country=json_data.getString("Country");
  
                  getArtists.add(ArtistRow);
              }
          }catch (Exception e){
              Log.e("log_tag","error3 " +  e.toString());
  
          }
  
          ArrayAdapter&lt;Artist&gt; adapter = new ArrayAdapter&lt;Artist&gt;(this, android.R.layout.simple_list_item_1, getArtists);
          ListView myListView =(ListView)findViewById(R.id.lvArtist);
          myListView.setAdapter(adapter);
   }
  }
  </code></pre>