Skip to content Skip to sidebar Skip to footer

Display A Single Row In A Listview (one Listview-entry For Every Column)

I want to display a single row from the database in a listview. For example: I have a database with three row and 4 columns. I want to display the columns from row 2 as a listview

Solution 1:

Okay now collect your data in cursor just get all your data and store each row object in a ArrayList of the wrapperClass object like

Cursor c=null;
        c=db.getAllRecords();
        if(c.getCount()>0)
        {
            for(int j=0;j<c.getCount();j++)
            {
                c.moveToPosition(j); 
                employeewrapper cw=new employeewrapper();
                cw.id=c.getLong(0);
                cw.name=c.getString(1);
                cw.phone=c.getString(2);
                cw.web=c.getString(3);
                cw.address=c.getString(4);
                cw.des=c.getString(5);
                cw.qual=c.getString(6);
                cw.doj=c.getString(7);
                cw.sal=c.getString(8);
                if(cw.des.equalsIgnoreCase("Designer"))
                {
                designers.add(cw);
                }
                } 
        }   
        c.close();
        db.close();

npw you can display any row you want create a new ArrayList of string to store names and pass that arraylist to the adapter in this way you can easily display your data and may be able to transfer it anywhere you want easily


Post a Comment for "Display A Single Row In A Listview (one Listview-entry For Every Column)"