Apps Android app using eclipse (Listview and SqlLite)

elbren

Lurker
Current Output: [[a],,[c]]

the output is like above which is i want to view from listview like:

a
b
c

here's my code at load my xml:

ArrayList<ArrayList<Object>> data = db.getAllRowsAsArrays();
String[] planets = new String[] { data.toString()};
ArrayList<String> planetList = new ArrayList<String>();
planetList.addAll( Arrays.asList(planets) );
listAdapter = new ArrayAdapter<String>(this, R.layout.simplerow, planetList);
mainListView.setAdapter( listAdapter );

here's is from my dbmanger:

private SQLiteDatabase db;
private final String DBNAME = "studentsdbNEW";
private final int DBVER = 1;
private final String TBLNAME = "students";

private final String SMYID = "myid";
private final String SMYFIRSTNAME = "myfname";
private final String SMYLASTNAME = "mylname";

my array:

public ArrayList<ArrayList<Object>> getAllRowsAsArrays()

{
ArrayList<ArrayList<Object>> dataArrays = new ArrayList<ArrayList<Object>>();
Cursor cursor;
try {
cursor = db.query(TBLNAME, new String[] { SMYID, SMYFIRSTNAME,
SMYLASTNAME }, null, null, null, null, null);
cursor.moveToFirst();
if (!cursor.isAfterLast()) {
do {
ArrayList<Object> dataList = new ArrayList<Object>();
dataList.add(cursor.getLong(0));
dataList.add(cursor.getString(1));

// dataList.add(cursor.getString(2));
dataArrays.add(dataList);
} while (cursor.moveToNext());
}
} catch (SQLException e) {
Log.e("DB Error", e.toString());
e.printStackTrace();
}
return dataArrays;
}
 

out of ideas

Android Enthusiast
Try using a hashmap to put it into the row you want

and post code online in code tags [ code] [/code] so others can read it easier and help you out better.
 
Top