我想創建一個基於字符串長度的gridView。在android中動態添加textView到gridView
每個TextView中應該表現出單個字符 - 下劃線 - 假設有字符串中沒有空間...
我以前沒有在C#中類似的東西 - 我craeted其中containes 15的tableview標籤,並根據字母的數量,移動他們每個人的權利。它看起來或多或少是這樣的:
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;
}
我希望做的GridView使用android系統中類似的東西,但不知道如何甚至開始...幫助...
如果textview的值是helloworld比你想在gridview中顯示helloworld像hll l o w o r l d嗎?我得到你嗎? – Zohaib
嗯...不完全...但如果你告訴我該怎麼做,生病了解:) – omi
你沒有看到任何方法讓你的代碼更簡單嗎? :) –