Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
October 2017
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031    

Calendar Calendar

RSS feeds


Yahoo! 
MSN 
AOL 
Netvibes 
Bloglines 


Social bookmarking

Social bookmarking Digg  Social bookmarking Delicious  Social bookmarking Reddit  Social bookmarking Stumbleupon  Social bookmarking Slashdot  Social bookmarking Yahoo  Social bookmarking Google  Social bookmarking Blinklist  Social bookmarking Blogmarks  Social bookmarking Technorati  

Bookmark and share the address of battle programmers alliance on your social bookmarking website

visual studio 2017 xamarin c# hello world walkthrough

View previous topic View next topic Go down

visual studio 2017 xamarin c# hello world walkthrough

Post  Moti Barski on Sat May 13, 2017 11:37 am

install visual studio with c# and xamarin checked, if you already have VS DL xamarin.

open your mobil device for developing search the walkthrough for your phone.

in the now visible phone developer options (on your phone), enable usb debugging

new project, c#, android, single view app
from solution explore, resources, layout, main xml, drag add button from the toolbox, save

from main.cs of solution explorer right side window : main.cs

add code :
Button button1 = FindViewById<Button>(Resource.Id.button1);

           button1.Click += delegate { button.Text = string.Format("hello world"); };

now your code is :
Code:
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace App8
{
    [Activity(Label = "App8", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
            // and attach an event to it
            Button button1 = FindViewById<Button>(Resource.Id.button1);

            button1.Click += delegate { button.Text = string.Format("hello world"); };
        }
    }
}
connect phone , click green arrow or f5

example for textview widget + button :
Code:
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace App8
{
    [Activity(Label = "App8", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);

            button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };
            // and attach an event to it
            Button button1 = FindViewById<Button>(Resource.Id.button1);
            TextView text1 = FindViewById<TextView>(Resource.Id.textView1);
            button1.Click += delegate { text1.Text = "hello world"; };
        }
    }
}

avatar
Moti Barski

Posts : 91
Join date : 2011-08-02

View user profile

Back to top Go down

Re: visual studio 2017 xamarin c# hello world walkthrough

Post  Moti Barski on Sat May 13, 2017 4:55 pm

after you finish debugging and unplug your mobile device turn off the developer options or your B8Tri will deplete very fast
avatar
Moti Barski

Posts : 91
Join date : 2011-08-02

View user profile

Back to top Go down

displaying a message

Post  Admin on Sat Jul 29, 2017 11:34 am

this is a faster way to display a message, use the toast message display spell :
Code:
Toast.MakeText(this, "hello world", ToastLength.Short).Show();
albino albino albino albino albino

_________________
kurayami no kagi
avatar
Admin
Admin

Posts : 58
Join date : 2011-08-01

View user profile https://yotamarker.justforum.net

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum