<i id='Llepe'><tr id='Llepe'><dt id='Llepe'><q id='Llepe'><span id='Llepe'><b id='Llepe'><form id='Llepe'><ins id='Llepe'></ins><ul id='Llepe'></ul><sub id='Llepe'></sub></form><legend id='Llepe'></legend><bdo id='Llepe'><pre id='Llepe'><center id='Llepe'></center></pre></bdo></b><th id='Llepe'></th></span></q></dt></tr></i><div id='Llepe'><tfoot id='Llepe'></tfoot><dl id='Llepe'><fieldset id='Llepe'></fieldset></dl></div>

        <tfoot id='Llepe'></tfoot>
        • <bdo id='Llepe'></bdo><ul id='Llepe'></ul>

        <small id='Llepe'></small><noframes id='Llepe'>

        <legend id='Llepe'><style id='Llepe'><dir id='Llepe'><q id='Llepe'></q></dir></style></legend>

      1. 点击 Viewpager Xamarin Android

        时间:2023-10-03

            <i id='ysFOL'><tr id='ysFOL'><dt id='ysFOL'><q id='ysFOL'><span id='ysFOL'><b id='ysFOL'><form id='ysFOL'><ins id='ysFOL'></ins><ul id='ysFOL'></ul><sub id='ysFOL'></sub></form><legend id='ysFOL'></legend><bdo id='ysFOL'><pre id='ysFOL'><center id='ysFOL'></center></pre></bdo></b><th id='ysFOL'></th></span></q></dt></tr></i><div id='ysFOL'><tfoot id='ysFOL'></tfoot><dl id='ysFOL'><fieldset id='ysFOL'></fieldset></dl></div>
              <tbody id='ysFOL'></tbody>
            • <bdo id='ysFOL'></bdo><ul id='ysFOL'></ul>

                <small id='ysFOL'></small><noframes id='ysFOL'>

                <tfoot id='ysFOL'></tfoot>

                <legend id='ysFOL'><style id='ysFOL'><dir id='ysFOL'><q id='ysFOL'></q></dir></style></legend>

                  本文介绍了点击 Viewpager Xamarin Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是 Xamarin Android Development 的新手.我使用 ViewPager 创建了图像滑块.现在我想点击该 ViewPager 的图像.我该如何实现?我已经尝试过了,但没有成功:

                  I am new to Xamarin Android Development.I have created Image slider using ViewPager.Now I want click on image of that ViewPager.How can I implement that ? I have tried this but not worked:

                  {
                    viewpage = mview.FindViewById<ViewPager> (Resource.Id.viewpager);
                    viewpage.Adapter = new itemadapter (ChildFragmentManager);
                    viewpage.Click += Viewpage_Click;
                  }
                  public void Viewpage_Click (object sender, EventArgs e)
                  {
                      ViewModel.DetailViewCommand.Execute ();
                  }
                  

                  推荐答案

                  如果你有 viewpager's 适配器,只需为 imageview 实现 onclick listener仅图像滑块.

                  Just implement onclick listener for imageview in viewpager's adapter if you have only image slider.

                  imageslider viewpager 的完整源代码,可从网络下载图像.

                  full source of imageslider viewpager that downloads images from web.

                  public class ImageSliderAdapter : PagerAdapter
                      {
                          Context _context;
                          List<string> _imageUrls;
                  
                          public ImageSliderAdapter (Context context, List<string> imageUrls)
                          {
                              _imageUrls = imageUrls;
                              _context = context;
                          }
                  
                          public override bool IsViewFromObject (Android.Views.View view, Java.Lang.Object @object)
                          {
                              return view == ((LinearLayout)@object);
                          }
                  
                          public override int Count {
                              get {
                                  return _imageUrls.Count;
                              }
                          }
                  
                          public override void DestroyItem (ViewGroup container, int position, Java.Lang.Object objectValue)
                          {
                          }
                  
                          public override Java.Lang.Object InstantiateItem (ViewGroup container, int position)
                          {
                  
                              View view = container;
                              var inflater = _context.GetSystemService (Context.LayoutInflaterService) as LayoutInflater;
                              view = inflater.Inflate (Resource.Layout.image_slider_item, null);
                              var child = view.FindViewById<ImageView> (Resource.Id.image_slider_item);
                              child.Click += (o, e) =>
                              {
                                  //your code here
                              };
                  
                              Bitmap image = null;
                              Task.Run (() => {
                                  URL url = new URL (_imageUrls [position]);
                                  image = BitmapFactory.DecodeStream (url.OpenConnection ().InputStream);
                              }).ContinueWith (t => {
                                  (_context as MainView).RunOnUiThread (() => {
                                      child.SetImageBitmap (image);
                                  });
                              });
                  
                              container.AddView (view);
                              return view;
                          }
                      }
                  

                  活动中:

                              var imageViewer = FindViewById<ViewPager> (Resource.Id.pager);
                              imageViewer.Adapter = new ImageSliderAdapter (this, imageUrls);
                  

                  这篇关于点击 Viewpager Xamarin Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:想要在 viewpager 上播放声音 滑动 下一篇:E/Web 控制台(8272):未捕获的 ReferenceError:未定义函数名称:1 在视图寻呼机中加载 web

                  相关文章

                • <small id='Da6il'></small><noframes id='Da6il'>

                • <i id='Da6il'><tr id='Da6il'><dt id='Da6il'><q id='Da6il'><span id='Da6il'><b id='Da6il'><form id='Da6il'><ins id='Da6il'></ins><ul id='Da6il'></ul><sub id='Da6il'></sub></form><legend id='Da6il'></legend><bdo id='Da6il'><pre id='Da6il'><center id='Da6il'></center></pre></bdo></b><th id='Da6il'></th></span></q></dt></tr></i><div id='Da6il'><tfoot id='Da6il'></tfoot><dl id='Da6il'><fieldset id='Da6il'></fieldset></dl></div>

                  1. <tfoot id='Da6il'></tfoot><legend id='Da6il'><style id='Da6il'><dir id='Da6il'><q id='Da6il'></q></dir></style></legend>

                    • <bdo id='Da6il'></bdo><ul id='Da6il'></ul>