How to make a table to display records from a SQLite database?
up vote
0
down vote
favorite
I got a simple question. I am trying to create some kind of layout that would display my records from SQLite Database in separate cells. I tried to make it using TextViews, but it is not what I expect. Do you know any ideas to create 'excel like' table with headers etc? What is more i need each row to be able to select and open (My goal is to have something like catalogue with products).
final TextView dTable= (TextView) findViewById(R.id.displayTable);
final ManageDatabase md = new ManageDatabase(this);
dTable.setText("");
for(Product p: md.takeAllProducts())
dTable.setText(dTable.getText()+"n"+" "+p.getProductCode()+" "+p.getProductName()+" "+p.getQuantity()+" "+p.getExpireDate());
java android android-sqlite
add a comment |
up vote
0
down vote
favorite
I got a simple question. I am trying to create some kind of layout that would display my records from SQLite Database in separate cells. I tried to make it using TextViews, but it is not what I expect. Do you know any ideas to create 'excel like' table with headers etc? What is more i need each row to be able to select and open (My goal is to have something like catalogue with products).
final TextView dTable= (TextView) findViewById(R.id.displayTable);
final ManageDatabase md = new ManageDatabase(this);
dTable.setText("");
for(Product p: md.takeAllProducts())
dTable.setText(dTable.getText()+"n"+" "+p.getProductCode()+" "+p.getProductName()+" "+p.getQuantity()+" "+p.getExpireDate());
java android android-sqlite
what does catalogue with products have to do with "excel like"? What exactly is your issue you are facing? What errors do you get? What do you mean by saying ...but it is not what I expect.. ?
– B001ᛦ
Nov 9 at 15:12
I mean I want to create table with rows and columns, where I can click on a row and open 'additional info' about product. My issue is that I can only display data from database but in one TextView field. What I expect is something like HTML table which I can put inside inside the loop to display all records.
– PeterMax00
Nov 9 at 15:20
You can use aGridLayout
– Augusto
Nov 9 at 15:20
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I got a simple question. I am trying to create some kind of layout that would display my records from SQLite Database in separate cells. I tried to make it using TextViews, but it is not what I expect. Do you know any ideas to create 'excel like' table with headers etc? What is more i need each row to be able to select and open (My goal is to have something like catalogue with products).
final TextView dTable= (TextView) findViewById(R.id.displayTable);
final ManageDatabase md = new ManageDatabase(this);
dTable.setText("");
for(Product p: md.takeAllProducts())
dTable.setText(dTable.getText()+"n"+" "+p.getProductCode()+" "+p.getProductName()+" "+p.getQuantity()+" "+p.getExpireDate());
java android android-sqlite
I got a simple question. I am trying to create some kind of layout that would display my records from SQLite Database in separate cells. I tried to make it using TextViews, but it is not what I expect. Do you know any ideas to create 'excel like' table with headers etc? What is more i need each row to be able to select and open (My goal is to have something like catalogue with products).
final TextView dTable= (TextView) findViewById(R.id.displayTable);
final ManageDatabase md = new ManageDatabase(this);
dTable.setText("");
for(Product p: md.takeAllProducts())
dTable.setText(dTable.getText()+"n"+" "+p.getProductCode()+" "+p.getProductName()+" "+p.getQuantity()+" "+p.getExpireDate());
java android android-sqlite
java android android-sqlite
edited Nov 10 at 9:11
Brian Tompsett - 汤莱恩
4,153133699
4,153133699
asked Nov 9 at 15:10
PeterMax00
31
31
what does catalogue with products have to do with "excel like"? What exactly is your issue you are facing? What errors do you get? What do you mean by saying ...but it is not what I expect.. ?
– B001ᛦ
Nov 9 at 15:12
I mean I want to create table with rows and columns, where I can click on a row and open 'additional info' about product. My issue is that I can only display data from database but in one TextView field. What I expect is something like HTML table which I can put inside inside the loop to display all records.
– PeterMax00
Nov 9 at 15:20
You can use aGridLayout
– Augusto
Nov 9 at 15:20
add a comment |
what does catalogue with products have to do with "excel like"? What exactly is your issue you are facing? What errors do you get? What do you mean by saying ...but it is not what I expect.. ?
– B001ᛦ
Nov 9 at 15:12
I mean I want to create table with rows and columns, where I can click on a row and open 'additional info' about product. My issue is that I can only display data from database but in one TextView field. What I expect is something like HTML table which I can put inside inside the loop to display all records.
– PeterMax00
Nov 9 at 15:20
You can use aGridLayout
– Augusto
Nov 9 at 15:20
what does catalogue with products have to do with "excel like"? What exactly is your issue you are facing? What errors do you get? What do you mean by saying ...but it is not what I expect.. ?
– B001ᛦ
Nov 9 at 15:12
what does catalogue with products have to do with "excel like"? What exactly is your issue you are facing? What errors do you get? What do you mean by saying ...but it is not what I expect.. ?
– B001ᛦ
Nov 9 at 15:12
I mean I want to create table with rows and columns, where I can click on a row and open 'additional info' about product. My issue is that I can only display data from database but in one TextView field. What I expect is something like HTML table which I can put inside inside the loop to display all records.
– PeterMax00
Nov 9 at 15:20
I mean I want to create table with rows and columns, where I can click on a row and open 'additional info' about product. My issue is that I can only display data from database but in one TextView field. What I expect is something like HTML table which I can put inside inside the loop to display all records.
– PeterMax00
Nov 9 at 15:20
You can use a
GridLayout
– Augusto
Nov 9 at 15:20
You can use a
GridLayout
– Augusto
Nov 9 at 15:20
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
accepted
You can use TableLayout
for it and dynamically add your content there.
First get the reference of table layout from XML file.
TableLayout myTable = (TableLayout) findViewById(R.id.mTable);
Then you can add retrieved data to the table dynamically like below
for(Product p: md.takeAllProducts())
//create new row
TableRow tableRow = new TableRow(this);
// create new text view
TextView textView1 = new TextView(this);
textView1.setText(p.getProductCode());
//add to row
tableRow.addView(textView1);
//create another text view and add to same row
TextView textView2 = new TextView(this);
textView2.setText(p.getProductName());
tableRow.addView(textView2);
//
TextView textView3 = new TextView(this);
textView3.setText(p.getQuantity());
tableRow.addView(textView3);
//
TextView textView4 = new TextView(this);
textView4.setText(p.getExpireDate());
tableRow.addView(textView4);
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
accepted
You can use TableLayout
for it and dynamically add your content there.
First get the reference of table layout from XML file.
TableLayout myTable = (TableLayout) findViewById(R.id.mTable);
Then you can add retrieved data to the table dynamically like below
for(Product p: md.takeAllProducts())
//create new row
TableRow tableRow = new TableRow(this);
// create new text view
TextView textView1 = new TextView(this);
textView1.setText(p.getProductCode());
//add to row
tableRow.addView(textView1);
//create another text view and add to same row
TextView textView2 = new TextView(this);
textView2.setText(p.getProductName());
tableRow.addView(textView2);
//
TextView textView3 = new TextView(this);
textView3.setText(p.getQuantity());
tableRow.addView(textView3);
//
TextView textView4 = new TextView(this);
textView4.setText(p.getExpireDate());
tableRow.addView(textView4);
add a comment |
up vote
0
down vote
accepted
You can use TableLayout
for it and dynamically add your content there.
First get the reference of table layout from XML file.
TableLayout myTable = (TableLayout) findViewById(R.id.mTable);
Then you can add retrieved data to the table dynamically like below
for(Product p: md.takeAllProducts())
//create new row
TableRow tableRow = new TableRow(this);
// create new text view
TextView textView1 = new TextView(this);
textView1.setText(p.getProductCode());
//add to row
tableRow.addView(textView1);
//create another text view and add to same row
TextView textView2 = new TextView(this);
textView2.setText(p.getProductName());
tableRow.addView(textView2);
//
TextView textView3 = new TextView(this);
textView3.setText(p.getQuantity());
tableRow.addView(textView3);
//
TextView textView4 = new TextView(this);
textView4.setText(p.getExpireDate());
tableRow.addView(textView4);
add a comment |
up vote
0
down vote
accepted
up vote
0
down vote
accepted
You can use TableLayout
for it and dynamically add your content there.
First get the reference of table layout from XML file.
TableLayout myTable = (TableLayout) findViewById(R.id.mTable);
Then you can add retrieved data to the table dynamically like below
for(Product p: md.takeAllProducts())
//create new row
TableRow tableRow = new TableRow(this);
// create new text view
TextView textView1 = new TextView(this);
textView1.setText(p.getProductCode());
//add to row
tableRow.addView(textView1);
//create another text view and add to same row
TextView textView2 = new TextView(this);
textView2.setText(p.getProductName());
tableRow.addView(textView2);
//
TextView textView3 = new TextView(this);
textView3.setText(p.getQuantity());
tableRow.addView(textView3);
//
TextView textView4 = new TextView(this);
textView4.setText(p.getExpireDate());
tableRow.addView(textView4);
You can use TableLayout
for it and dynamically add your content there.
First get the reference of table layout from XML file.
TableLayout myTable = (TableLayout) findViewById(R.id.mTable);
Then you can add retrieved data to the table dynamically like below
for(Product p: md.takeAllProducts())
//create new row
TableRow tableRow = new TableRow(this);
// create new text view
TextView textView1 = new TextView(this);
textView1.setText(p.getProductCode());
//add to row
tableRow.addView(textView1);
//create another text view and add to same row
TextView textView2 = new TextView(this);
textView2.setText(p.getProductName());
tableRow.addView(textView2);
//
TextView textView3 = new TextView(this);
textView3.setText(p.getQuantity());
tableRow.addView(textView3);
//
TextView textView4 = new TextView(this);
textView4.setText(p.getExpireDate());
tableRow.addView(textView4);
answered Nov 10 at 3:32
Lucefer
8001510
8001510
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228337%2fhow-to-make-a-table-to-display-records-from-a-sqlite-database%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
what does catalogue with products have to do with "excel like"? What exactly is your issue you are facing? What errors do you get? What do you mean by saying ...but it is not what I expect.. ?
– B001ᛦ
Nov 9 at 15:12
I mean I want to create table with rows and columns, where I can click on a row and open 'additional info' about product. My issue is that I can only display data from database but in one TextView field. What I expect is something like HTML table which I can put inside inside the loop to display all records.
– PeterMax00
Nov 9 at 15:20
You can use a
GridLayout
– Augusto
Nov 9 at 15:20