List View Array from Database
Posted
by
leenolasco
on Stack Overflow
See other posts from Stack Overflow
or by leenolasco
Published on 2012-10-01T09:36:31Z
Indexed on
2012/10/01
9:37 UTC
Read the original article
Hit count: 120
android
I have retrieved data and successfully shown it in text view.
What do i modify in my codes to make it look like a list view?
And also how do modify my listview programatically(adding size and padding)?
Here is my a part of my DBclass in selecting the items that I've displayed
getFAData() {
// TODO Auto-generated method stub
String [] columns = new String[]{Row_Name};
Cursor c = ourDB.query(db_Table, columns, null, null, null, null, null);
String res = "";
int iRow = c.getColumnIndex(Row_Name);
//int iDesc = c.getColumnIndex(Row_Desc);
//int iID = c.getColumnIndex(Row_id);
for (c.moveToFirst(); !c.isAfterLast(); c.moveToNext())
{
res = res + c.getString(iRow) + "\n";
}
return res;
}
And here is class file:
public class FirstAid extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.firstaid);
displayresult();
}
public void displayresult (){
TextView tvFa = (TextView) findViewById(R.id.tvFA);
tvFa.setMovementMethod(new ScrollingMovementMethod());
DbHelper tblFa = new DbHelper(this);
tblFa.open();
String result = tblFa.getFAData();
tblFa.close();
tvFa.setText(result);
}
}
© Stack Overflow or respective owner