#![cfg(target_os = "android")] #![allow(rustdoc::missing_crate_level_docs)] // it's an example use android_logger::Config; use eframe::egui; use log::LevelFilter; use winit::platform::android::activity::AndroidApp; #[no_mangle] fn android_main(app: AndroidApp) { // Log to android output android_logger::init_once(Config::default().with_max_level(LevelFilter::Info)); let options = eframe::NativeOptions { android_app: Some(app), ..Default::default() }; eframe::run_native( "My egui App", options, Box::new(|cc| { // This gives us image support: egui_extras::install_image_loaders(&cc.egui_ctx); Ok(Box::::default()) }), ) .unwrap() } struct MyApp { name: String, age: u32, } impl Default for MyApp { fn default() -> Self { Self { name: "Arthur".to_owned(), age: 42, } } } impl eframe::App for MyApp { fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { egui::CentralPanel::default().show(ctx, |ui| { ui.heading("My egui Application"); ui.horizontal(|ui| { let name_label = ui.label("Your name: "); ui.text_edit_singleline(&mut self.name) .labelled_by(name_label.id); }); ui.add(egui::Slider::new(&mut self.age, 0..=120).text("age")); if ui.button("Increment").clicked() { self.age += 1; } ui.label(format!("Hello '{}', age {}", self.name, self.age)); ui.image(egui::include_image!( "../../../crates/egui/assets/ferris.png" )); }); } }