How to build a Custom Dialog in Xamarin works with lifetime events | CodeNameK - 16

Опубликовано: 04 Ноябрь 2024
на канале: Code with Saar
823
7

Sharing steps to build a reliable Android Custom Dialog and the caveats to avoid. Key take away:

DialogFragment requires a default constructor to working properly with FragmentManager.
Attach listeners to DialogFragment by overwriting `OnAttach` method.
Resource (R) is auto-compiled static class that holds various of constants for resource access.
Logcat is useful debugging crash.
Android developer guide is a useful resource for Xamarin.Android development.

For more video like this:
💡Subscribe: https://www.youtube.com/c/CodewithSaa...

Resources

Android Developer Guide: https://developer.android.com/guide

Demo code:

https://github.com/xiaomi7732/CodeWit...

Discord server for Code w/ Saar:   / discord  

Reach me on twitter @CodeWithSaar. My home page: https://www.codewithsaar.net

If you want to buy me a coffee: https://www.buymeacoffee.com/codewith... and thank you!

Chapters

00:00 Intro
00:51 Build a dialog with AlertDialog.Builder
03:17 Build the dialog in DialogFragment
06:46 Invoke DialogFragment
07:55 Wrong way to hook up button click
10:17 Troubleshooting the crash caused by the wrong implementation
12:17 The correct way to hook up button click
16:45 Customize the dialog with an Android layout
20:06 Set view using resource id for custom content
20:56 Get value from the input - manually inflate the layout xml into objects
24:15 Troubleshooting the unexpected error
25:53 Correct the mistake, make it work