ползунок нижней вкладки xamarin android - PullRequest
0 голосов
/ 01 апреля 2020

У меня проблема с добавлением элементов и событий в tab_slide_bottom.

URL основного проекта

введите описание ссылки здесь

мой полный код

введите описание ссылки здесь

TheFragmentLayout, imageView1

   public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var view = inflater.Inflate(Resource.Layout.TheFragmentLayout, container, false);
            var imageView = view.FindViewById<ImageView>(Resource.Id.imageView1);

            int resID = (int)typeof(Resource.Drawable).GetField(_icon).GetValue(null);
            imageView.SetImageResource(resID);

            var textView = view.FindViewById<TextView>(Resource.Id.Title);
            textView.SetText(_title, null);

            return view;
        }

1 Ответ

1 голос
/ 01 апреля 2020

Пожалуйста, откройте файл TheFragment.cs, для которого NameSpace установлено значение BottomNavigationViewPager, измените его на пространство имен вашего проекта tab_slide_bottom

namespace tab_slide_bottom.Fragments
{
    public class TheFragment : Fragment
    {
        string _title;
        string _icon;

        public static TheFragment NewInstance(string title, string icon)
        {
            var fragment = new TheFragment();
            fragment.Arguments = new Bundle();
            fragment.Arguments.PutString("title", title);
            fragment.Arguments.PutString("icon", icon);
            return fragment;
        }

        public override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            if (Arguments != null)
            {
                if (Arguments.ContainsKey("title"))
                    _title = (string)Arguments.Get("title");

                if (Arguments.ContainsKey("icon"))
                    _icon = (string)Arguments.Get("icon");
            }
        }

        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
           // res
            var view = inflater.Inflate(Resource.Layout.fragment_layout, container, false);
            var imageView = view.FindViewById<ImageView>(Resource.Id.imageView1);

            int resID = (int)typeof(Resource.Drawable).GetField(_icon).GetValue(null);
            imageView.SetImageResource(resID);

            var textView = view.FindViewById<TextView>(Resource.Id.my_title);
            textView.SetText(_title, null);

            return view;
        }
    }
}

Вот ваш код, выполняющий GIF.

enter image description here

Вот ваш проект, вы можете скачать его.

https://github.com/851265601/Xamarin.Android_ListviewSelect/blob/master/tab_slide_bottom.zip

...