游戏王中国
2022-06-16 16:43
采纳率: 77.8%
浏览 17

ViewPager问题

问题遇到的现象和发生背景
问题相关代码,请勿粘贴截图
 base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            // Create your application here
            viewPapgeTitle = FindViewById<ViewPager>(Resource.Id.viewPager1);
            viewLists = new List<View>();
            LayoutInflater li = LayoutInflater;
            viewLists.Add(li.Inflate(Resource.Layout.layout1, null, false));
            viewLists.Add(li.Inflate(Resource.Layout.layout2, null, false));
            viewLists.Add(li.Inflate(Resource.Layout.layout3, null, false));
            titleList = new List<string>() {
                "红褐色","黄色","白色"
            };
            adapter = new MyPagerAdapter2(viewLists, titleList);
            viewPapgeTitle.Adapter = adapter;

            LinearLayout LinearLayout_获取布局 = (LinearLayout)li.Inflate(Resource.Layout.layout1, null);
            button_layout1 = (Button)LinearLayout_获取布局.FindViewById(Resource.Id.button_layout1);
            按钮事件无效
            button_layout1.Click += Button_layout1_Click1;
            LinearLayout LinearLayout_获取布局2 = (LinearLayout)li.Inflate(Resource.Layout.layout2, null);
            button_layout2 = (Button)LinearLayout_获取布局2.FindViewById(Resource.Id.button_layout2);
            按钮事件无效
            button_layout2.Click += Button_layout2_Click;


运行结果及报错内容

按钮事件无效
button_layout2.Click += Button_layout2_Click;

我的解答思路和尝试过的方法

按钮事件无效
button_layout2.Click += Button_layout2_Click;

我想要达到的结果

按钮为什何无效
按钮不为空

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题