是否可以將文本動態添加到 xalm 中定義的多個文本視圖?例如,在一個回圈中:
var textView1 = FindViewById<TextView>(Resource.Id.textView1);
var textView2 = FindViewById<TextView>(Resource.Id.textView2);
var textView3 = FindViewById<TextView>(Resource.Id.textView3);
var content = "Add me to more at one textView"
for (i = 1; i = 3; i )
{
// add me;
}
我可以很容易地做到這一點,因為它通過在布局中呼叫 GetChildAt() 以編程方式添加文本視圖。如果在 xalm 中定義了 textView,是否可以添加動態?
uj5u.com熱心網友回復:
假設您的文本 ID 是 text1、text2、tex3 等。使用:
for (int i=1; i<numberOfTextsViews; i ) {
int id = this.getResources().getIdentifier("text" i, "id", getPackageName());
TextView temp = findViewById(id);
temp.setText("text you want to add to all your texts");
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/341613.html
