Bonjour,

Bon j'ai un gros problème de débutant ce qui est mon cas! je suis en trains de coder un livre comme une application jusque-là pas de souci particulier j'utilise 2 menu le premier et un option menu qui se trouve en haut à droite est qui me sert de table des matières et le second un menu qui est une navigation drawer activity.

Mon gros souci est là où je perds un temps fou c'est que le livre fait environ 450 pages et comme je veux que les menus soient disponibles sur chacune des pages je suis obligé non seulement de reporter mon code sur autant de fichier class que compte de pages XML mais en plus je suis obligé de mettre à jours l'intégralité de celle-ci à chaque fois que je rajoute une page XML donc une class etc.

Je pense qu'il est possible d’appeler le même fichier exemple menu.class.

Pour info je n'utilise pas de fragment mais un fichier xml/class pour 2 pages réel du livre.

Alors oui je ces surement coder comme Picasso calculant la théorie de Boole (en gros comme de la merde) il faut le dire mais comme je n'avais aucune notion n'y référence j'apprends à la voler avec BCP de tuto surement aussi pourri que mon code!

Petit extrais de la page_002.class sachant que j'en suis à 60 est que j'en ai plein le ... de faire du copier-coller à chaque fois que je crée une page.xml je dois faire une page.xml recopier le code dedans en ajoutant le code du menu et actualiser les 60 autre page etc...


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
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
package glouton1er.com;
 
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
 
public class page_002 extends AppCompatActivity
        implements NavigationView.OnNavigationItemSelectedListener {
 
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.page_002);
 
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
 
        DrawerLayout drawer = findViewById(R.id.drawer_layout);
        NavigationView navigationView = findViewById(R.id.nav_view);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.addDrawerListener(toggle);
        toggle.syncState();
        navigationView.setNavigationItemSelectedListener(this);
    }
 
    @Override
    public void onBackPressed() {
        DrawerLayout drawer = findViewById(R.id.drawer_layout);
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }
 
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }
 
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        int id = item.getItemId();
 
        if (id == R.id.Auteurs) {
            Intent intent = new Intent(page_002.this, page_002.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Tome) {
            Intent intent = new Intent(page_002.this, page_003.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Noooon) {
            Intent intent = new Intent(page_002.this, page_004.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Finch) {
            Intent intent = new Intent(page_002.this, page_005.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Intro) {
            Intent intent = new Intent(page_002.this, page_006.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Automne) {
            Intent intent = new Intent(page_002.this, page_007.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_008) {
            Intent intent = new Intent(page_002.this, page_008.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.La_Lune) {
            Intent intent = new Intent(page_002.this, page_009.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Image_La_Lune) {
            Intent intent = new Intent(page_002.this, page_010.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_011) {
            Intent intent = new Intent(page_002.this, page_011.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_012) {
            Intent intent = new Intent(page_002.this, page_012.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_013) {
            Intent intent = new Intent(page_002.this, page_013.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_014) {
            Intent intent = new Intent(page_002.this, page_014.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.ronny) {
            Intent intent = new Intent(page_002.this, page_015.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_016) {
            Intent intent = new Intent(page_002.this, page_016.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_017) {
            Intent intent = new Intent(page_002.this, page_017.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_018) {
            Intent intent = new Intent(page_002.this, page_018.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_019) {
            Intent intent = new Intent(page_002.this, page_019.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.lebureau1) {
            Intent intent = new Intent(page_002.this, page_020.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_021) {
            Intent intent = new Intent(page_002.this, page_021.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_022) {
            Intent intent = new Intent(page_002.this, page_022.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_023) {
            Intent intent = new Intent(page_002.this, page_023.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_024) {
            Intent intent = new Intent(page_002.this, page_024.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_025) {
            Intent intent = new Intent(page_002.this, page_025.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_026) {
            Intent intent = new Intent(page_002.this, page_026.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_027) {
            Intent intent = new Intent(page_002.this, page_027.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_028) {
            Intent intent = new Intent(page_002.this, page_028.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_029) {
            Intent intent = new Intent(page_002.this, page_029.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.Page_030) {
            Intent intent = new Intent(page_002.this, page_030.class);
            startActivity(intent);
            return true;
 
        }
        if (id == R.id.page_031) {
            Intent intent = new Intent(page_002.this, page_031.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_032) {
            Intent intent = new Intent(page_002.this, page_032.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_033) {
            Intent intent = new Intent(page_002.this, page_033.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_034) {
            Intent intent = new Intent(page_002.this, page_034.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_035) {
            Intent intent = new Intent(page_002.this, page_035.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_036) {
            Intent intent = new Intent(page_002.this, page_036.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_037) {
            Intent intent = new Intent(page_002.this, page_037.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_038) {
            Intent intent = new Intent(page_002.this, page_038.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_039) {
            Intent intent = new Intent(page_002.this, page_039.class);
            startActivity(intent);
            return true;
        }
        if (id == R.id.page_040) {
            Intent intent = new Intent(page_002.this, page_040.class);
            startActivity(intent);
            return true;
 
        }
 
        return super.onOptionsItemSelected(item);
    }
 
    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        // Handle navigation view item clicks here.
        int id = item.getItemId();
 
        if (id == R.id.nav_home) {
            // Handle the camera action
        } else if (id == R.id.nav_gallery) {
 
        } else if (id == R.id.nav_slideshow) {
 
        } else if (id == R.id.nav_tools) {
 
        } else if (id == R.id.nav_share) {
 
        } else if (id == R.id.nav_send) {
 
        }
 
        DrawerLayout drawer = findViewById(R.id.drawer_layout);
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
 
    public void page_003(View view) {
        startActivity(new Intent(this, page_003.class));
    }
}
C'est pour cela que je vous demande de l'aide
Voila en vous remerciant d'avance.