Bonjour à tous
J'ai un problème qui m'occupe depuis plusieurs jours.
J'essai de faire fonctionner un menu option dans une actionbar en suivant plusieurs tuto dont celui de Maxime Esprit. Si je télécharge son exemple, tout fonctionne. Quand je transpose dans mon appli, j'ai l'erreur en objet après la génération, au moment de lancer dans l'émulateur.

Mon top_menu.xml
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
<?xml version="1.0" encoding="utf-8" ?>
<Menu
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.abdroid.com/apk/res-auto">
  <Item
    android:id="@+id/moreOption"
    android:title="i"
    app:showAsAction="never"/>
</Menu>

Mon activity_main.xml
Code XML : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
 
  <LinearLayout
        android:id="@+id/Layout_Body"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/action_bar">
 
          <GridLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:columnCount="2"
            android:rowCount="9"
            android:layout_marginLeft="20px"
            android:layout_marginRight="20px">
 
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="0"
                android:layout_column="0"
                android:text="BatchName" />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="1"
                android:text=" " />
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="2"
                android:text="Production Order"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="3"
                android:text=" "/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="4"
                android:text="Item Code"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="5"
                android:text=" "/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="6"
                android:text="Produced Quantity"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="7"
                android:text="+"/>
            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_column="0"
                android:layout_row="8"
                android:text="Scrap Quantity"/>
 
            <EditText
                android:id="@+id/TB_Batchname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="0"
                android:layout_column="1"
                android:inputType="textCapCharacters"
                android:textSize="@dimen/design_tab_text_size"
                android:text=""
                android:hint="Operator initials"/>
            <TextView
                android:id="@+id/L_Batchname"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="1"
                android:layout_column="1"/>
            <EditText
                android:id="@+id/TB_ProductionOrder"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="2"
                android:layout_column="1"
                android:inputType="textCapCharacters"
                android:textSize="@dimen/design_tab_text_size"
                android:text=""
                android:hint="PO Code"/>
             <TextView
                android:id="@+id/L_ProductionOrder"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="3"
                android:layout_column="1"/>
            <EditText
                android:id="@+id/TB_Item"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="4"
                android:layout_column="1"
                android:inputType="textCapCharacters"
                android:textSize="@dimen/design_tab_text_size"
                android:text=""
                android:hint=""
                android:textStyle="bold"
                android:enabled="false"/>
            <TextView
                android:id="@+id/L_Item"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="5"
                android:layout_column="1"/>
            <EditText
                android:id="@+id/TB_Quantity"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="6"
                android:layout_column="1"
                android:inputType="numberDecimal"
                android:text=""/>
            <EditText
                android:id="@+id/TB_Scrap"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_row="8"
                android:layout_column="1"
                android:inputType="numberDecimal"
                android:text=""/>
 
          </GridLayout>
 
      </LinearLayout>
 
     <LinearLayout
        android:id="@+id/Layout_Bottom"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@id/Layout_Body">
     <Button
         android:id="@+id/B_Post"
         android:layout_width="match_parent"
         android:layout_height="wrap_content"
         android:textAlignment="center"
         android:text="Post"/>
 
     </LinearLayout>
</LinearLayout>

Et mon MainActivity.cs
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
namespace NAV_Production_Statement
{
        [Activity(Label = "@string/app_name", Theme = "@style/ActionBarTheme", MainLauncher = true)]
    public class MainActivity : AppCompatActivity
    {
        private EditText TB_BatchName;
        private TextView L_BatchName;
        private EditText TB_ProductionOrder;
        private TextView L_ProductionOrder;
        private EditText TB_Item;
        private TextView L_Item;
        private EditText TB_Quantity;
        private EditText TB_Scrap;
        private Button B_Post;
        private string Operation;
        private PostOutputJournal wsPOJ = new PostOutputJournal();
 
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);
            TB_BatchName = FindViewById<EditText>(Resource.Id.TB_Batchname);
            L_BatchName = FindViewById<TextView>(Resource.Id.L_Batchname);
            TB_ProductionOrder = FindViewById<EditText>(Resource.Id.TB_ProductionOrder);
            L_ProductionOrder = FindViewById<TextView>(Resource.Id.L_ProductionOrder);
            TB_Item = FindViewById<EditText>(Resource.Id.TB_Item);
            L_Item = FindViewById<TextView>(Resource.Id.L_Item);
            TB_Quantity = FindViewById<EditText>(Resource.Id.TB_Quantity);
            TB_Scrap = FindViewById<EditText>(Resource.Id.TB_Scrap);
            B_Post = FindViewById<Button>(Resource.Id.B_Post);
            TB_BatchName.FocusChange += TB_BatchName_Focus_changed;
            TB_ProductionOrder.FocusChange += TB_ProductionOrder_Focus_changed;
            TB_ProductionOrder.TextChanged += TB_ProductionOrder_TextChanged;
            B_Post.Click += delegate { B_Post_Click(); };
        }
 
        public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)
        {
            MenuInflater.Inflate(Resource.Menu.top_menu, menu);
            return true;
        }
 
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
        {
            Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
 
            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
        }
Je n'ai mis que le début.
Si je commente OnCreateOptionsMenu, tout fonctionne correctement.
Je ne sais plus où chercher. Merci d'avance pour toute indication que vous pourriez me donner.

Frédéric