I’m trying to create a gridView based on a length of a string.
Every textView should show a single char – an underline – and assuming that there are no space in the string…
I’ve Previously did something similar in c#-
I craeted a tableview which containes 15 lables, and based on the number of letters, moved each of them the the right. it looks more or less like this:
public void setLetters(String str)
{
tableLayoutPanel1.Visible = false;
int x = revah(str); //revah returns the number of letters in the string
int yy = x / 2;
int count = 0;
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl0, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl1, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl2, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl3, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl4, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl5, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl6, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl7, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl8, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl9, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl10, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl11, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl12, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl13, yy);
count++;
}
if (count <= x)
{
tableLayoutPanel1.SetColumn(lbl14, yy);
count++;
}
tableLayoutPanel1.Visible = true;
}
I wish to do something similar in android, using gridView, but have no idea how to even start… help…
Follow this link
this will show how to make grid view , what u want now. u have to make an method that will read you textview value and then make a logic to split those word in single character and than add those character in string[] . Hope this will help