【发布时间】:2017-09-07 23:29:13
【问题描述】:
我在主 Activity 的布局中添加了一个控件 (TextView)。我要原版的
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:text="@string/currentLenguajeLabel"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/TextViewCurrentLenguajeLabel" />
</LinearLayout>
然后在代码中我得到这样的控件:
TextView myControl = FindViewById<TextView>(Resource.Id.TextViewCurrentLenguajeLabel);
如何获取控件的名称(TextViewCurrentLenguajeLabel)?
我需要将其发送到翻译功能
我知道那是名称,但我需要将名称发送给方法。我想避免做这样的事情
myControl.Text = localizationMethod(“TextViewCurrentLenguajeLabel”);
我想做这样的事情
myControl.Text = localizationMethod(myControl.GetControlName());
【问题讨论】:
-
这是 TextView 的名称 - 你的意思是如何获取 TextView 的文本?
-
我知道那是名称,但我需要将名称发送到我想避免做这样的事情
myControl.tText = localizationMethod(“TextViewCurrentLenguajeLabel”);我想做这样的事情myControl.tText = localizationMethod(myControl.GetControlName());跨度> -
我明白你的意思,或者,至少我认为我明白了。我会在下面尝试回答。
标签: c# xamarin.android