xamarin-“ Resource.Id”不包含“ btnSave”,“ btnAddPic”,“ etSalary”,“ etName”的定义

时间:2018-11-08 18:36:09

标签: xamarin button resources edit id

我有下一个代码:

EditActivity:

DirectorySlash Off

edit_activity:

using System;
using Android.App;
using Android.Content;
using Android.Graphics;
using Android.OS;
using Android.Widget;

namespace _23._10App
{
    public class EditActivity : Activity
    {
        Button btnSave, btnAddPic;
        EditText etSalary, etName;
        Bitmap bitmap;
        ImageView ivProduct;
        int pos = -1;

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.edit_layout);

            ivProduct = FindViewById<ImageView>(Resource.Id.iv);

            btnSave = FindViewById<Button>(Resource.Id.btnSave);
            btnAddPic = FindViewById<Button>(Resource.Id.btnAddPic);

            etSalary = FindViewById<EditText>(Resource.Id.etSalary);
            etName = FindViewById<EditText>(Resource.Id.etName);
            pos = Intent.GetIntExtra("pos", -1);//-1 is default
            btnSave.Click += BtnSave_Click;
            btnAddPic.Click += BtnAddPic_Click;

但是该程序无法运行。我有4个错误-

  1. “ Resource.Id”不包含“ btnSave”的定义
  2. “ Resource.Id”不包含“ btnAddPic”的定义
  3. 'Resource.Id'不包含'etSalary'的定义
  4. “ Resource.Id”不包含“ etName”的定义。

我试图做所有事情,但仍然无法正常工作。有人可以帮我吗?

0 个答案:

没有答案