有没有办法动态搜索 TextView? (赛马林)

Is there a way to search for a TextView dynamically? (Xamarin)

我正在尝试动态查找 textView 的资源 ID。我需要它根据输入的每个名称在布局中找到每个 TextView。

据我所知:

        String test = "t12";
        //Just an idea I had on how to get it.Doesnt work
        var r = (TextView)test;
        TextView t = FindViewById <TextView>(Resource.Id.r);

如有任何帮助,我们将不胜感激...:)

以下代码有效:

        String test = "t12";
        int resID = Resources.GetIdentifier(test, "id", PackageName);
        var k = (TextView)FindViewById(resID);
        k.Text = "Hello World";

你不能这样解析......

字符串测试="t12";

var r = (TextView)test;

这样试试...

TextView textView = new TextView(this);

textView.Text = "some text";