Skip to content Skip to sidebar Skip to footer

Converting String Into Textview?

Have a look at this code: ArrayList row = data.get(position); TextView idText = new TextView(this); idText.setText(row.get(0).toString()); tableRow.addView(idText);

Solution 1:

///you did mistake while copy paste

//idText using in all Tv

let do it as below

TextView idText = new TextView(this);
        idText.setText(row.get(0).toString());
        tableRow.addView(idText);

        TextView storeText = new TextView(this);
        storeText.setText(row.get(1).toString());
        tableRow.addView(storeText);

        TextView maggiText = new TextView(this);
        maggiText.setText(row.get(2).toString());
        tableRow.addView(maggiText);

Solution 2:

ArrayList row = data.get(position);

for(int i=0; i<row.size(); i++)
{
    TextView text= new TextView(this);
    idText.setText(row.get(i).toString());
    tableRow.addView(idText);
}

Post a Comment for "Converting String Into Textview?"