CS0117 C#"Resource.Id"不包含"PhoneNumberText"的定义. [英] CS0117 C# 'Resource.Id' does not contain a definition for "PhoneNumberText"

查看:126
本文介绍了CS0117 C#"Resource.Id"不包含"PhoneNumberText"的定义.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Visual Studio 2015与Xamarin一起使用. 我将我的项目命名为"Phoneword" 我在Xamarin的网站上看到了诸如教程/示例之类的代码.

I use Visual Studio 2015 with Xamarin. I'm naming my project "Phoneword" I see this code such as tutorial/example on Xamarin's site.

TranslateButton CallButton 成员的错误相同.

MainActivity.cs

using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace Phoneword
{
[Activity(Label = "Phoneword", MainLauncher = true)]
public class MainActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.Main);

        // Our code will go here
        // Get our UI controls from the loaded layout:
        EditText phoneNumberText = (EditText)FindViewById(Resource.Id.PhoneNumberText);
        Button translateButton = FindViewById<Button>(Resource.Id.TranslateButton);
        Button callButton = FindViewById<Button>(Resource.Id.CallButton);

        // Disable the "Call" button
        callButton.Enabled = false;

        // Add code to translate number
        string translatedNumber = string.Empty;

        translateButton.Click += (object sender, EventArgs e) =>
        {
            // Translate user's alphanumeric phone number to numeric
            translatedNumber = Core.PhonewordTranslator.ToNumber(phoneNumberText.Text);
            if (String.IsNullOrWhiteSpace(translatedNumber))
            {
                callButton.Text = "Call";
                callButton.Enabled = false;
            }
            else
            {
                callButton.Text = "Call " + translatedNumber;
                callButton.Enabled = true;
            }
        };

        callButton.Click += (object sender, EventArgs e) =>
        {
            // On "Call" button click, try to dial phone number.
            var callDialog = new AlertDialog.Builder(this);
            callDialog.SetMessage("Call " + translatedNumber + "?");
            callDialog.SetNeutralButton("Call", delegate {
                // Create intent to dial phone
                var callIntent = new Intent(Intent.ActionCall);
                callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber));
                StartActivity(callIntent);
            });
            callDialog.SetNegativeButton("Cancel", delegate { });

            // Show the alert dialog to the user and wait for response.
            callDialog.Show();
        };
    }

}
}

资源/布局/Main.axml

<?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="Enter a Phoneword"
        android:textAppearance="?android:attr/textAppearanceLarge"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/textView1" />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/PhoneNumberText"
        android:text="1-855-XAMARIN" />
    <Button
        android:text="Translate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/TranslateButton" />
    <Button
        android:text="Call"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/CallButton" />
</LinearLayout>

我是Android开发中的初学者,如果您需要其他信息,我会尝试添加更多详细信息. 请帮助我

I'm beginner in Android development, if you need other information i'll try to add more detail. Please help me

推荐答案

我解决了我的问题! 从工具/Android SDK管理器中我卸载了:

I solved my problem! From Tools/Android SDK Manager I uninstalled:

  • Android SDK构建工具24
  • Android N(API 24)

我安装了:

  • Android 6.0(API 23)
  • Android SDK构建工具23.0.3
  • Android SDK Build-tools 23.0.2

在我关闭VS并重新启动它之后...在解决方案资源管理器中,选择清理解决方案",然后选择重建解决方案".

After I closed VS and I restarted it... In the Solution Explorer I selected "Clean Solution" and after I selected "Rebuild Solution".

这篇关于CS0117 C#"Resource.Id"不包含"PhoneNumberText"的定义.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆