Android - Retrieve all data from a SQLite table row

Posted by Paul on Stack Overflow See other posts from Stack Overflow or by Paul
Published on 2012-12-18T23:01:20Z Indexed on 2012/12/18 23:02 UTC
Read the original article Hit count: 169

Filed under:
|
|

I have searched and cannot find an answer to my issue so i hope i am not completely barking up the wrong tree (so to speak).

I am new to android and have started to create an app. My app on one screen creates and adds entries to a SQLite database using public class DatabaseHandler extends SQLiteOpenHelper and this all appears to work.

I retrieve all the data and populate it into a grid, again this now works.

My issue is I am unable to retrieve one complete line from the grid.

I populate/display the grid with the following code.

I have cut a lot out as the grid is made in stages, header, blank lines etc but the grid does display as I want.

The id’s work as when I touch a line it displays its unique id.

The onClick is right at the end and when I use getText() instead of getID() all it returns is the data in the labelDate. How do I retrieve all the labels as listed below?

TextView labelDATE = new TextView(this);
TextView labelCP = new TextView(this);
TextView labelBG = new TextView(this);
TextView labelQA = new TextView(this);
TextView labelCN = new TextView(this);
TextView labelKT = new TextView(this);
TextView[] tvArray = {labelDATE, labelCP, labelBG, labelQA, labelCN, labelKT};
labelDATE.setText(re.getTime());
labelCP.setText(re.getCP());
labelBG.setText(re.getBG());
labelQA.setText(re.getQA());
labelCN.setText(re.getCN());
labelKT.setText(re.getKT());
for (TextView tv : tvArray)
{
    tv.setTextColor(Color.WHITE);
    tv.setId(200+count);
    tr.setOnClickListener(this);
    tr.addView(tv);
}
//add this to the table row
tl.addView(tr, new TableLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));

public void onClick(View v) 
{ 
    if (v instanceof TableRow) 
    { 
        TableRow row = (TableRow) v; 
        TextView child = (TextView) row.getChildAt(0); 
        Toast toast = Toast.makeText(this, String.valueOf(child.getId()), Toast.LENGTH_SHORT); 
        toast.show();
    } 
}

I can supply all the code for the grid creation if required.

Thanks for any help.

© Stack Overflow or respective owner

Related posts about android

Related posts about sqlite