I already know how to add String's to a gridView in android however I want to add textviews to format the text( Gravity, color, etc). This is my current code:
GridView gridView = (GridView) findViewById(R.id.grades);
ArrayList<TextView> display = new ArrayList<TextView>();
ArrayAdapter<TextView> adapter = new ArrayAdapter<TextView>(this,
android.R.layout.simple_list_item_1, display);
gridView.setAdapter(adapter);
for(int i = 0; i<currentClass.grades.size(); i++)
{
TextView name = new TextView(this);
TextView weight = new TextView(this);
TextView cur_points = new TextView(this);
TextView total_points = new TextView(this);
TextView cur_percent = new TextView(this);
name.setText(currentClass.grades.get(i).name);
weight.setText(currentClass.grades.get(i).weight);
cur_points.setText(currentClass.grades.get(i).cur_points);
total_points.setText(currentClass.grades.get(i).total_points);
cur_percent.setText(currentClass.grades.get(i).cur_percent);
name.setTextColor(Color.WHITE);
weight.setTextColor(Color.WHITE);
cur_points.setTextColor(Color.WHITE);
total_points.setTextColor(Color.WHITE);
cur_percent.setTextColor(Color.WHITE);
name.setSingleLine(true);
weight.setSingleLine(true);
cur_points.setSingleLine(true);
total_points.setSingleLine(true);
cur_percent.setSingleLine(true);
name.setGravity(Gravity.LEFT);
weight.setGravity(Gravity.RIGHT);
cur_points.setGravity(Gravity.RIGHT);
total_points.setGravity(Gravity.RIGHT);
cur_percent.setGravity(Gravity.RIGHT);
display.add(name);
display.add(weight);
display.add(cur_points);
display.add(total_points);
display.add(cur_percent);
adapter.notifyDataSetChanged();
}
Unfortunately when I run it the gridview simply gives me the information of each TextView: "android.id.widget.TextView({42f20a88 and so on}.
How would I add textview's to a gridView?