Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/184.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在Mono for Android中使用strings.xml_C#_Android_Xamarin.android - Fatal编程技术网

C# 在Mono for Android中使用strings.xml

C# 在Mono for Android中使用strings.xml,c#,android,xamarin.android,C#,Android,Xamarin.android,我正在将android SDK与Microsoft VS2010 C#配合使用。我想在我的C#代码中使用/resources/values/strings文件中的字符串值。下面是一段代码,说明了我想做什么。我没有得到字符串值。我知道资源id是一个int,但我需要的是该id后面的实际字符串值 void vx2OkButton_Click(object sender, EventArgs e) { Log.Info(LOG_TAG, "Hello from O

我正在将android SDK与Microsoft VS2010 C#配合使用。我想在我的C#代码中使用/resources/values/strings文件中的字符串值。下面是一段代码,说明了我想做什么。我没有得到字符串值。我知道资源id是一个int,但我需要的是该id后面的实际字符串值

        void vx2OkButton_Click(object sender, EventArgs e)
    {
        Log.Info(LOG_TAG, "Hello from OkButton|Enter()button");  // also used as Enter button
        strVx20kButtonText = vx2OkButton.Text.ToString();
        mDwnLdCodeEnteredByUser = vxxDwnldCodeEntered.Text.Trim();
        string strDwnldCodeOut = mActCode.Bad.ToString();

        if(strVx20kButtonText == Resource.String.Enter.ToString())
        {
            if (mDwnLdCodeEnteredByUser.Length < 1)
            {
                vxxSystemMsgBox.SetText(Resource.String.FieldRequried_);
                m_txvEnterDwnLdCode.SetTextAppearance(this,Resource.Color.Red);
                return;
            }
            // verify the dwnldcodeenter by the user matches the assigned to user when at the time the downloaded the app 

            mDwnLoadStatus = VerifyDwnLoadCode(mDwnLdCodeEnteredByUser);

            if (mDwnLoadStatus == mDwnLdStatCode.BadDwnLdCode.ToString())
            {
                vxxSystemMsgBox.SetText(Resource.String.InvalidValueEntered);
                m_txvEnterDwnLdCode.SetTextAppearance(this, Resource.Color.Red);
                return;
            }

            mActionCD = mActCode.Ok.ToString();
            vx2OkButton.SetText(Resource.String.OkButtonText);
            vxxSystemMsgBox.SetText(Resource.String.ThanksPressOkButton);
            m_txvEnterDwnLdCode.SetTextAppearance(this,Resource.Color.White);
            return;
        }
void vx2OkButton_单击(对象发送器,事件参数e)
{
Log.Info(Log_标记,“Hello from OkButton | Enter()按钮”);//也用作Enter按钮
strVx20kButtonText=vx2OkButton.Text.ToString();
mDwnLdCodeEnteredByUser=vxxDwnldCodeEntered.Text.Trim();
字符串strDwnldCodeOut=mActCode.Bad.ToString();
if(strvx20kbuttonext==Resource.String.Enter.ToString())
{
如果(mDwnLdCodeEnteredByUser.Length<1)
{
vxxSystemMsgBox.SetText(Resource.String.FieldRequried);
m_txvEnterDwnLdCode.settextearance(这个,Resource.Color.Red);
返回;
}
//验证用户的DWNLDCodeCenter与下载应用程序时分配给用户的匹配
mDwnLoadStatus=VerifyDwnLoadCode(mDwnLdCodeEnteredByUser);
如果(mDwnLoadStatus==mDwnLdStatCode.BadDwnLdCode.ToString())
{
vxxSystemMsgBox.SetText(Resource.String.InvalidValueEntered);
m_txvEnterDwnLdCode.settextearance(这个,Resource.Color.Red);
返回;
}
mActionCD=mActCode.Ok.ToString();
vx2OkButton.SetText(Resource.String.okbuttonext);
vxxSystemMsgBox.SetText(Resource.String.ThanksPressOkButton);
m_txvEnterDwnLdCode.settextearance(这个,Resource.Color.White);
返回;
}

正如您所注意到的,Resource.String.Enter是为您生成的整数,您可以使用该整数访问字符串资源。您可以使用以下方法访问它:


正如您所注意到的,Resource.String.Enter是为您生成的整数,您可以使用它访问字符串资源。您可以使用以下方法访问它:


如果您将非工作示例减少到显示错误所需的最低代码,您将有更好的运气获得问题的答案。这样做甚至可能帮助您找到解决方案!目前,在粘贴的函数中,潜在的回答者无法理解的内容太多了。如果您将不工作的示例减少到显示错误所需的最少代码。这样做甚至可以帮助您找到解决方案!目前,在粘贴的函数中,有太多的内容让潜在的回答者无法理解。
string enter = Resources.GetString(Resource.String.Enter);