Results 1 to 26 of 26

Thread: xamarin hello world

  1. #1

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    xamarin hello world

    I opened a new blank app project added a button and clicked the run button
    with the code :
    Code:
    using Android.App;
    using Android.Widget;
    using Android.OS;
    
    namespace App2
    {
        [Activity(Label = "App2", MainLauncher = true, Icon = "@drawable/icon")]
        public class MainActivity : Activity
        {
            protected override void OnCreate(Bundle bundle)
            {
                base.OnCreate(bundle);
    
                // Set our view from the "main" layout resource
                SetContentView (Resource.Layout.Main);
                Button btn = FindViewById<Button>(Resource.Id.button1);
                TextView lbl = FindViewById<TextView>(Resource.Id.button1);
    
                btn.Text = "Click Me!";
    
                btn.Click += delegate
                {
                    lbl.Text = "Hello world";
                };
            }
        }
    }
    in the main class and all I get is a black screen.
    also I am logged to my xamarin account.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    110,348

    Re: xamarin hello world

    Are you asking a question? The CodeBank forums are for sharing working code snippets. If you need help with an issue then use the Report Post icon under you post to send a message to the mods asking to move this thread to the appropriate forum.

  3. #3

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    yes, my bad.
    I looked 4 D xamarin forum.

  4. #4
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: xamarin hello world

    Yeah, there isn't one at this time. Xamarin could be considered C#, as that's generally the language used, but much of Xamarin and issues with Xamarin isn't really C# related, so C# is pretty much just the syntax. Therefore, I'm moving the thread to General Developer for lack of a better place, at the moment.
    My usual boring signature: Nothing

  5. #5
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: xamarin hello world

    Maybe the phone related forum?

  6. #6
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: xamarin hello world

    Yeah your probably not setup correctly.

    Xamarin is a pain at the beginning, and it doesn't really tell you what your missing when things aren't working correctly.

    I actually posted a setup guide i created for Xamarin Forms in another Thread. Now it looks like your using Xamarin Android so you can ignore the stuff specifically to do with Xamarin Forms but the rest of the setup is basically the same!

    Here is the Thread, you will need to scroll down a bit to find my post with the Setup guide link in it - Xamarin Setup

    The other bit you can ignore is the Section on the Android Emulator. I have removed that from my latest version as the standard Emulator you can chose from the Run Drop Down does work, i was having some issues which i thought were Emulator related but turns out it was something else and the Standard Emulator was fine.

    Hopefully some of the info will help you.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  7. #7
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: xamarin hello world

    Shaggy isn't there a Mobile Development Forum where this would more naturally fit?
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  8. #8
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: xamarin hello world

    Xamarin doesn't fully fall into any category. It CAN be used for mobile development, and that may well be the most common use (aside from being used to raise the blood pressure for people suffering from low pressure). As it is now built into VS, and assuming that MS keeps going with it, there will likely end up being a need for a forum dedicated to it.....but I'm not advocating that, just yet.
    My usual boring signature: Nothing

  9. #9

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    pressed the debug green arrow, after waiting a long time the emulator turned on but my hello world was no where to be found,
    also I don't know how to exit the debug emulator, and I need to turn it off from the task manager.
    xamarin is heaven and earth inferior than what it is portrayed online.

    also I can't double click a button I add from the toolbox to code the click event it has to be coded completely by typing.
    not to mention the emulator is an ugly nexus 5.

  10. #10
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: xamarin hello world

    Quote Originally Posted by bugsi View Post
    xamarin is heaven and earth inferior than what it is portrayed online.
    I spent a couple months working with it, after which I can only say: Amen!!
    My usual boring signature: Nothing

  11. #11
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: xamarin hello world

    pressed the debug green arrow, after waiting a long time the emulator turned on but my hello world was no where to be found
    You never said did you take a look at my setup document?

    Also are you just using XAML to display your form? as if you build your form using C# (which i have found a nicer experience overall i dont think the XAML Forms stuff is mature enough yet) you can debug even the building of your form layout not just the data part, and then you can step through and see why your Hello World is not displaying.

    also I don't know how to exit the debug emulator, and I need to turn it off from the task manager.
    Well on my Emulator it has a floating bar next to it with a great big X button which will close it down, not sure which one your using, if you just want to stop your app running then just press stop in VS. I do this more often as the Emulator takes a while to load, and its a lot quicker loading if you just leave you Emulator open and just shut it down at the end of the day.

    xamarin is heaven and earth inferior than what it is portrayed online.
    also I can't double click a button I add from the toolbox to code the click event it has to be coded completely by typing.
    Xamarin has its issues and it lacks any decent sort of Visual Forms editor, although my understanding they are looking to integrate it with Blend so you can visually design your forms like in Win Phone apps, but i have found once i got past the learning curve i am fairly productive creating apps in it.

    If your using VS2015 it will create the Click Event for you if after you have written button.Click += and then press Tab a couple of times

    not to mention the emulator is an ugly nexus 5.
    You can change your Emulator that is just the default, and you can also choose to debug directly on a Device if your prefer

    I spent a couple months working with it, after which I can only say: Amen!!
    Well i know you dont like it at all Shaggy, and while i agree there are issues with it particularly in the initial setup i haven't found it as bad. I would be interested to know what you biggest issues with Xamarin were?

    I have also recently being doing a fair amount of web development and you dont have a forms editor there either, but i suppose if your coming straight from Desktop development to Xamarin then it is going to feel like a bigger jump.

    Until recently Xamarin was a fairly small company, since its purchase by MS the couple of updates they have put out have seemed to make it more stable and improved things, i am expecting MS to invest in it as a Product so it will be interesting to see if we see it maturing in the next year or so.

    One other thing i will add, is i am using the MVVMLight Framework which is really great, MVVM is similar to MVC and using this framework is one of the best decisions i made when working with Xamarin.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  12. #12
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    39,043

    Re: xamarin hello world

    To clarify my position: I feel it's currently half baked. There are loads of bugs, but none of them completely stop you. What is most noticeably missing, though, is information, and this is why I am hopeful for the future of Xamarin now that MS has acquired it. Any new language you get into is going to cause some problems. The way you used to muddle through was by buying books. These days, the way you muddle through is with online documentation, forums, and so forth. Those things don't really exist for Xamarin, yet. To be sure, there is a little documentation out there, but it's often incomplete, inadequate, inconsistent, or even incorrect. However, one thing that MS does pretty well is documenting things and doing so clearly and consistently. Furthermore, the fact that Xamarin is built into VS means that there will be more use of it, so more forums, more resources, and so forth.

    So, I feel it's currently half baked, and would have remained that way had MS not bought it. What it mostly needs to advance is not a better form editor, bug fixes, new features, or anything like that, nice though they might be. What it mostly needs is explanation, both about things that work as expected, and those that don't...unless they get changed at the same time. These are the things that are easiest for MS to supply, and, in my opinion, these are the things that would most rapidly improve the Xamarin experience.

    On the other hand, I'm now working in Cordova, which is ALSO included into VS, and that has me a bit puzzled. I'm not sure quite what the differentiation is between Xamarin and Cordova, at least for Android.
    My usual boring signature: Nothing

  13. #13

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    when I click the emulator X it closes the emulator and keeps on debugging and vs2017 is stuck.
    and the hello world app isn't showing in the emulator to begin with. I tried following step by step with
    the hello world tutorial vids on youtube for some reason it doesn't work for me and it works for them, most of them
    have a hindu accent so maybe there they got some different version or something , really this is beyond me.

    so I would like to know how to uninstall just the xamarin from vs2017, cause the hello world works on jdk + android studio.

  14. #14
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: xamarin hello world

    Android dev is a particularly sore spot IMO. For the past five months I haven't been able to keep a Debug build of anything Android open for more than 5-10s before it crashed.

    There's an emulator you might consider trying called Genymotion. You can probably still get a free version to try out for a bit. It works a million times better than the stock Android simulators, and honestly I've never had Microsoft's version of it work for me at all. You might consider giving that a whirl.

    I don't think Xamarin's as bad as Shaggy Hiker makes it out to be, but the past three years have made me wonder why anyone writes apps for Android at all. I can't fathom going through that much pain daily. iOS is a lot smoother, both in Xamarin and out.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  15. #15

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    I really wouldn't mind paying if it worked smoothly. because of their false advertising I wasted time learning c#.

  16. #16
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: xamarin hello world

    I really wouldn't mind paying if it worked smoothly. because of their false advertising I wasted time learning c#.
    It's never wasted time learning C# its a great language, and Xamarin are hardly going to try and put you off trying out their products are they, that would be a terrible business model.

    To clarify my position: I feel it's currently half baked. There are loads of bugs, but none of them completely stop you. What is most noticeably missing, though, is information, and this is why I am hopeful for the future of Xamarin now that MS has acquired it.
    Fair enough that makes sense, one thing i will say they have done a couple of releases lately which are definitely more stable and for me at least cut out some stupid compile bugs i was getting for no apparent reason. It feels less buggy now, however one area were i wholeheartedly agree with you is there is definitely still a lack of decent documentation and support.

    I got a little lucky in the regard that i decided on the MVVMLight Framework first, and there are example projects out there on the internet of using Xamarin + MVVMLight which really helped me a lot in getting started.
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  17. #17
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: xamarin hello world

    Honestly I feel like their messaging is muddled.

    It's priced fairly *now*. Just last year it was $1,500 per product per seat, so if you wanted to do both iOS and Android you needed to pay $3,000/year. That was appropriate for the amount of engineering effort they put in but bonkers for the kind of user MS is known for targeting. That's why MS changed it to being included with the ~$500 VS Pro license.

    I think it always has been, and for the near future will be, most appropriate for relatively large companies' internal applications. The layout system is mostly oriented towards pages that are fairly static, particularly with respect to changes in orientation. Doing anything sophisticated tends to involve writing custom renderers, which requires some domain knowledge in the native Android and/or iOS layout systems. The more dynamic and fancy you try to get the higher the prices you tend to pay. I wouldn't want to try and write something like Tweetbot in Xamarin. But it's fine for writing a lot of other apps without flash, glitz, and glamor.

    For small organizations, the only attractive thing might be "we already have the license because we bought Visual Studio". It's almost a guarantee the talent at this level is very WinForms-oriented, and everything mobile resembles WPF more closely.

    For the hobbyist, it's a heck of a lot cheaper to just learn Java and write Android code, and/or Swift for iOS code. The main benefit of Xamarin Forms is being able to leverage C# and WPF knowledge to get UI on many devices. That's a good proposition for smallish organizations that can't afford to have a C# AND Android AND iOS team. It's also a good proposition for Microsoft shops, because people on the MS stack tend to be so suspicious of non-MS options they'll never consider others.

    If you truly feel learning C# was a waste of time, Xamarin's not for you. There's dozens of other things you're going to have to learn that aren't "VB with WinForms", and most of them aren't easy. Developing for mobiles is very weird compared to developing for desktops. The OS can kill your app at any time while it's backgrounded. You can't have two "windows" on the screen at once outside of oddball Android scenarios. You don't have a swap file so if you are memory-heavy there's a very real possibility you'll be terminated with no warning. You can never know if you have network connectivity from moment-to-moment. Filesystem access is extremely restricted. At any time, a phone call might interrupt your application. If you take too long to start up, you can be terminated. You're limited in what you can do in the background. None of these constraints are Xamarin's fault, but they're things you'll have to learn to deal with that can also be exacerbated because you're jamming a runtime in between you and the phone.

    If you want a rewarding path to hobbyist mobile development, pick up some iOS or Android books and skip the C# middleman. If you want to do it in VB, your most viable option is UWP apps. But truth be told: mobile development is very ugly, and filled with many pitfalls. It makes Windows look VERY friendly.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  18. #18
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: xamarin hello world

    I can't disagree with any of that, but these days phones and tablets have a lot more RAM and CPU horsepower to work with. The only thing that constrains them is really the lack of plentiful, fast, reliable mass storage.

    That's the main reason there is no virtual memory, and that in turn was the original reason why mobile OSs have the application model they do. Which in turn helps explain why development for mobile is a bit awkward.

    If a cheap, robust, and viable substitute for the disk drive ever arrives that could change, but it doesn't mean it will.

  19. #19
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: xamarin hello world

    Honestly if you're wanting to support a wide variety of devices (read: the majority of Android) it's still uncommon to find 1GB of RAM. And when you're cramming a new garbage-collected runtime on top of the OS's existing garbage-collected runtime and having to cooperate with all the other apps on a system, you can get in situations where you really miss being able to zap some memory now. Our app's really memory-hungry and we have to be super careful with it.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  20. #20
    Member
    Join Date
    Dec 2010
    Posts
    41

    Re: xamarin hello world

    If you want a rewarding path to hobbyist mobile development, pick up some iOS or Android books and skip the C# middleman. If you want to do it in VB, your most viable option is UWP apps.
    A better option for VB developers is available: http://www.vbforums.com/showthread.p...=1#post5140893

    (I'm the CEO of Anywhere Software)
    Last edited by Erel; Apr 16th, 2017 at 04:02 AM.

  21. #21

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    I connected a Samsung galaxy s7 edge choose the devise from the debug drop down arrow and it worked

  22. #22

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    the code itself doesn't work, the .id gives an err

  23. #23

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world


  24. #24
    You don't want to know.
    Join Date
    Aug 2010
    Posts
    4,578

    Re: xamarin hello world

    It's a person yelling at a computer monitor while holding a smartphone. They produce a critique of Xamarin Studio on the same level of discourse as Palladium Software's world famous Microshaft Winblows 98.
    This answer is wrong. You should be using TableAdapter and Dictionaries instead.

  25. #25
    Superbly Moderated NeedSomeAnswers's Avatar
    Join Date
    Jun 2002
    Location
    Manchester uk
    Posts
    2,660

    Re: xamarin hello world

    It not just any person yelling at a computer its Moti, how the hell did you come across that particular video?

    ... and why post a link to it? if that is what you watching to try and learn Xamarin then no wonder you failed !!!
    Please Mark your Thread "Resolved", if the query is solved & Rate those who have helped you



  26. #26

    Thread Starter
    Banned
    Join Date
    Aug 2016
    Posts
    62

    Re: xamarin hello world

    it is 3:42 AM I finally got it to work, needsomeanswers did not, yet you had to drop by and use shaming language against a member of the battle programming alliance.
    no wonder I failed ? the online tutorials and documentations left out vitally important info. moti's walkthroughs are simple and tested working.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width