[英]How can I open a new window/page using Xamarin for an Android App?
我正在設置一個新的 Android 應用程序。 當我單擊一個按鈕時,我試圖打開一個新窗口/頁面失敗了。
我知道使用 WPF 時它是如何工作的,但我是 Xamarin 的新手。 我想要的是這個: Window w1 = new Window()
;
所以當我點擊這個按鈕時,會出現一個特定的窗口/頁面。
我試過以下:
Button button = FindViewById<Button>(Resource.Id.button1);
button.Click += delegate { StartActivity(typeof(settings)) };
我在互聯網上找不到任何東西。
我知道你想在 android 中單擊按鈕開始另一個活動
你可以這樣做:
Button button = FindViewById<Button>(Resource.Id.button1);
button.Click += delegate {
Intent intent = new Intent(this, typeof(YOURSECONDACTIVITYHERE));
startActivity(intent);
};
注意:這不是跨平台代碼,僅適用於 Android。 我建議您在 Xamarin 共享項目文件中查找教程並編寫代碼。 如果您以后想為其他系統擴展您的項目。
在 xamarin android 中存在 Intent class。 它 class 幫助您切換到其他活動。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.