嗨,伙计们,你能在C#中给我一个setOnTouchListener的例子吗?我试过这样但是我带来了一些错误.
Button1.setOnTouchListener(new View.OnTouchListener()
{
public boolean onTouch(View arg0, MotionEvent arg1)
{
x.Text = "1";
}
});
Run Code Online (Sandbox Code Playgroud) 嗨,大家好,我需要一些建议.我试图使用Xamarin创建一个Android应用程序,所以C#.我制作了两个布局,在每一个布局中我制作了两个按钮来在它们之间导航.我试着这样:
using System;
using Android.App;
using Android.OS;
using Android.Views;
using Android.Widget;
namespace Example
{
[Activity(Label = "Example", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(Resource.Layout.Main);
this.FindViewById<Button>(Resource.Id.ForwardButton).Click += this.Forward;
this.FindViewById<Button>(Resource.Id.BackButton).Click += this.Back;
}
public void Forward(object sender, EventArgs e)
{
this.SetContentView(Resource.Layout.Main2);
}
public void Back(object sender, EventArgs e)
{
this.SetContentView(Resource.Layout.Main);
}
}
}
Run Code Online (Sandbox Code Playgroud)
但每当我启动应用程序时,我都会得到这样的错误:System.NullReferenceException已被抛出.对象引用未设置为对象的实例.有什么建议或更好的想法?
嗨,大家好我有点问题.我试图设置EditText的最大长度,但我没有成功.
我试过这样的:
a.setFilters (new InputFilter[] { new InputFilter.LengthFilter (a.Length) });
Run Code Online (Sandbox Code Playgroud)
我得到一些错误(不是在a.Length).
和这样:
a.setMaxLength ( a.Lenght);
Run Code Online (Sandbox Code Playgroud)
还有一些错误.
我想我忘记了一些标题,但这只是猜测.
提示我使用Xamarin.先感谢您.