Class Cast Exception in getting ListView Value getItem
<p>Ahm Yester I post my code about my problem on viewing the data in the listview using listfragment. I got the solution and it works fine. But now the problem is the getItem function is returning an error saying "java.lang.classcastexception : java.lang.string". Here is my code:</p>

<p>My listfragment:</p>

<pre><code>public class ListTest2 extends ListFragment {



      @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        // TODO Auto-generated method stub

          ListAdapter listAdapter = getListAdapter();
          Log.i("here","here");
          ListSql cc = (ListSql) listAdapter.getItem(position);



          //Toast.makeText(getActivity(), "" + l.getSelectedItem() ,Toast.LENGTH_LONG).show();
          ArrayList&lt;String&gt; arr = new ArrayList&lt;String&gt;();
         Log.i("",cc.getName());


    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onActivityCreated(savedInstanceState);

        List&lt;ListSql&gt; results = new ArrayList&lt;ListSql&gt;();
        ArrayList&lt;String&gt; arr = new ArrayList&lt;String&gt;();
        HotorNot hon = new HotorNot(getActivity());
        hon.open();
        arr = hon.listme(arr);
        hon.close();
        Toast.makeText(getActivity(), arr.toString(), Toast.LENGTH_LONG).show();
        setListAdapter(new SqlParser(getActivity(),arr));
      } 
}
</code></pre>

<p>My ListSql Class:</p>

<pre><code>public class ListSql {


    private String Fname;
    private String Fpass;
    private ArrayList&lt;String&gt; arList;

    private Context myContext;
    private List&lt;ListSql&gt; items;
    private LayoutInflater  mInflater;
    private DBhelper myHelper;
    private SQLiteDatabase myDbase;

    public static final String KEY_ROWID = "_id";
    public static final String KEY_NAME = "_persons_name";
    public static final String KEY_HOTNESS = "person_hotness";

    private static final String DATABASE_NAME = "HotOrNotdb";
    private static final String DATABASE_TABLE = "peopleTable";
    private static final int DATABASE_VERSION = 1;


    public static class DBhelper extends SQLiteOpenHelper{

        public DBhelper(Context context) {
            super(context, DATABASE_NAME, null, DATABASE_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            db.execSQL(
                    "Create Table " + DATABASE_TABLE + " (" + 
                    KEY_ROWID + " Integer PRIMARY KEY AUTOINCREMENT, " + 
                    KEY_NAME + " TEXT NOT NULL, " + 
                    KEY_HOTNESS + " TEXT NOT NULL);"
                    );

        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub
            db.execSQL("DROP TABLE IF EXIST " + DATABASE_TABLE);
            onCreate(db);
        }

    }


    public String getName(){
        return Fname;
    }

    public String getPass(){

        return Fpass;
    }




    public ListSql open(){
        myHelper = new DBhelper(myContext);
        myDbase = myHelper.getWritableDatabase();
        Log.i("open","open");
        return this;
    }
    public void close(){
        myHelper.close();

    }


    public ArrayList&lt;String&gt; Listme(ArrayList&lt;String&gt; arr){
        String sql = "select * from " + DATABASE_TABLE;
        Cursor c = myDbase.rawQuery(sql, null);
        if(c !=null){
            if  (c.moveToFirst()) {
                do {
                    String firstName = c.getString(c.getColumnIndex(KEY_NAME));
                    String pass = c.getString(c.getColumnIndex(KEY_HOTNESS));
                    arr.add("username " + firstName + ",  Password: " + pass);

                }while (c.moveToNext());
            } 

            return arr;

        }

        return null;

    }

}
</code></pre>

<p>AND my Baseadapter:</p>

<pre><code>public class SqlParser extends BaseAdapter {

    private Context myContext;
    private ArrayList&lt;String&gt; items;
    private LayoutInflater  mInflater;
    private DBhelper myHelper;
    private SQLiteDatabase myDbase;

    public static final String KEY_ROWID = "_id";
    public static final String KEY_NAME = "_persons_name";
    public static final String KEY_HOTNESS = "person_hotness";

    private static final String DATABASE_NAME = "HotOrNotdb";
    private static final String DATABASE_TABLE = "peopleTable";
    private static final int DATABASE_VERSION = 1;


    public SqlParser(Context context ,ArrayList&lt;String&gt; arr){
        this.myContext = context;
        this.items = arr;
        mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }


    private class ViewHolder {
        public TextView textView;
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return items.size();
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return items.get(position);
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return 0;
    }



    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub
        ArrayList&lt;String&gt; arr = new ArrayList&lt;String&gt;();
        View view = convertView;
        ViewHolder viewHolder;
        TextView namef ;
        ImageView prof;
        Bitmap bMap;
        if (view == null) {
            view = mInflater.inflate(R.layout.listinflate, parent, false);

            /**
            viewHolder = new ViewHolder();
            viewHolder.textView = (TextView) view.findViewById(R.id.textView1);
            view.setTag(viewHolder); **/


            /*** You can do this manualy without using holder ***/
             namef = (TextView)view.findViewById(R.id.textView1);

            /*** You can do this manualy on setting the tag to individual components rather than using holder  ***/ 
            view.setTag(namef);

        }else {
            viewHolder = (ViewHolder) view.getTag();
            namef = (TextView) view.getTag();

        }
        namef.setText(items.get(position));

        return view;
    }
}
</code></pre>

<p>I dont What Causing this error. thanks</p>
