使用xamarin在android中的网格视图中编辑文本

时间:2014-02-21 12:34:30

标签: c# xamarin gtk# xamarin-studio

朋友们,我喜欢使用带有c#的xamarin进行移动应用。在网格视图中有一个编辑文本。当输入数字并单击后退按钮时,值不显示意味着页面正在刷新以解决问题

    public override Android.Views.View GetView(int position, Android.Views.View convertView, Android.Views.ViewGroup parent)
    {

        int row = GetRow(position);
        var item = PositionToString(position);
        var txtName = convertView as TextView ?? new TextView(context);

        if (row == 0)
        {
            txtName.SetBackgroundResource(Resource.Drawable.textview2);
            txtName.SetHeight(40);
            txtName.SetText(item, TextView.BufferType.Normal);
            txtName.SetTextColor(Android.Graphics.Color.Black);

        }
        else
        {
            txtName.SetText(item, TextView.BufferType.Normal);
            txtName.SetTextColor(Android.Graphics.Color.Black);
            txtName.SetHeight(40);
            txtName.SetBackgroundResource(Resource.Drawable.textview1);
        }
        if (position % 3 == 2)
        {
            if (row == 0)
            {

                txtName = convertView as TextView ?? new TextView(context);
                txtName.SetHeight(40);

                txtName.SetTextColor(Android.Graphics.Color.Black);
                txtName.SetBackgroundResource(Resource.Drawable.textview2);                   
            }
            else
            {

                txtName = convertView as EditText ?? new EditText(context);
                txtName.SetHeight(40);
                txtName.SetText(item, EditText.BufferType.Normal);
               txtName.SetBackgroundResource(Resource.Drawable.grideditextbackground);
               txtName.InputType = Android.Text.InputTypes.ClassNumber;


            }
        }

        return txtName;
    }
}

}

0 个答案:

没有答案