0
我正在创建一个Android应用程序,其中主屏幕上有LISTVIEW。与LISTVIEW相关的LISTITEM包含一个IMAGEVIEW(共享图标)。我试图显示意图选择器共享LISTITEM的内容的Onclick事件,但我的问题是,如果我不对屏幕上显示的INTENT选择器执行任何操作,并且如果我只是尝试按硬件返回按钮,目前显示的意图选择器不会消失,它仍然保留在屏幕上。经过多次尝试按下后退按钮,尝试3-4次后消失。我其实不想要这种不寻常的行为,它应该在第一次尝试时消失。意图选择器不会在单击时消失
public override View GetView (int position, View convertView, ViewGroup parent)
{
var item = items [position];
View view = convertView;
if (view == null)
view = context.LayoutInflater.Inflate (Resource.Layout.HadithListViewItem, null);
string HadithText = string.Empty;
string BookName = string.Empty;
string ChapterName = string.Empty;
view.FindViewById<TextView> (Resource.Id.HadithText).Text = items [position].HadithText;
HadithText = view.FindViewById<TextView> (Resource.Id.HadithText).Text;
BookName = items[position].BookName;;
ChapterName = items[position].ChapterName.ToString()+ "-" + items[position].HadithID.ToString();
ImageView share = view.FindViewById<ImageView> (Resource.Id.ShareButton);
share.Click += (object sender2, EventArgs e2) => {;
Intent sharingIntent = new Intent(Android.Content.Intent.ActionSend);
sharingIntent.SetType("text/plain");
String shareBody = HadithText;
sharingIntent.PutExtra(Android.Content.Intent.ExtraSubject, BookName + "(" + ChapterName + ")\n");
sharingIntent.PutExtra(Android.Content.Intent.ExtraText, shareBody);
this.context.StartActivity(Intent.CreateChooser(sharingIntent, "Share via"));
};
view.FindViewById<TextView> (Resource.Id.HadithBook).Text = BookName;
view.FindViewById<TextView>(Resource.Id.HadithChapter).Text = ChapterName;
view.SetOnClickListener (null);
return view;
}
+符号是强制性的......它显示编译错误out +,而且我只添加一次。 –