{"id":42473,"date":"2024-01-10T11:06:20","date_gmt":"2024-01-10T03:06:20","guid":{"rendered":"https:\/\/www.yimenapp.com\/kb-yimen\/?p=42473"},"modified":"2024-01-10T11:06:20","modified_gmt":"2024-01-10T03:06:20","slug":"vs2015%e5%bc%80%e5%8f%91%e5%ae%89%e5%8d%93app%e7%99%bb%e5%bd%95%e7%95%8c%e9%9d%a2%e6%80%8e%e4%b9%88%e5%81%9a%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.yimenapp.com\/kb-yimen\/42473\/","title":{"rendered":"vs2015\u5f00\u53d1\u5b89\u5353app\u767b\u5f55\u754c\u9762\u600e\u4e48\u505a\uff1f"},"content":{"rendered":"<p>\u5728Visual Studio 2015\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 Xamarin \u5f00\u53d1\u5de5\u5177\u521b\u5efa\u8de8\u5e73\u53f0\u7684\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\uff0c\u5305\u62ec Android \u548c iOS\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f1a\u6f14\u793a\u5982\u4f55\u5728 Visua<a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353APP\u5f00\u53d1<\/a>l Studio 2015 \u5185\u4f7f\u7528 Xamarin \u5f00\u53d1 Android \u5e94\u7528\u7a0b\u5e8f\uff0c\u5e76\u4e3a\u8be5\u5e94\u7528\u521b\u5efa\u4e00\u4e2a\u767b\u5f55<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e7%95%8c%e9%9d%a2\/\" title=\"\u754c\u9762\" target=\"_blank\">\u754c\u9762<\/a><\/span>\u3002<\/p>\n<p># \u51c6\u5907\u5de5\u4f5c<\/p>\n<p>1. \u5b89\u88c5 Visual Studio 2015\uff08Community\u3001Professional \u6216 Enterprise\u7248\u672c\u5747\u53ef\uff09\u3002<\/p>\n<p>2. \u5b89\u88c5 Xamarin\u3002\u901a\u5e38\u5728 Visual Studio \u5b89\u88c5\u8fc7\u7a0b\u4e2d\u53ef\u4ee5\u9009\u62e9 Xamarin \u4f5c\u4e3a\u4e00\u4e2a\u7ec4\u4ef6\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5 Xamarin\uff0c\u53ef\u4ee5\u5728 https:\/\/www.xamarin.com \u5b9e\u73b0\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002<\/p>\n<p># \u521b\u5efa Android \u9879\u76ee<\/p>\n<p>1. \u6253\u5f00 Visual Studio 2015\uff0c\u9009\u62e9 &#8220;\u65b0\u5efa\u9879\u76ee&#8230;&#8221;\u3002<\/p>\n<p>2. \u5728\u6a21\u677f\u4e2d\u9009\u62e9 &#8220;Installed &gt; Templates &gt; Visual C# &gt; Android &gt; Blank App\uff08Android\uff09&#8221;\u3002<\/p>\n<p>3. \u4e3a\u9879\u76ee\u547d\u540d\uff0c\u4f8b\u5982 &#8220;LoginApp&#8221;\uff0c\u7136\u540e\u70b9\u51fb &#8220;\u786e\u5b9a&#8221;\u3002<\/p>\n<p>Visual Studio \u5c06\u4f1a\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u57fa\u4e8e Xamarin \u7684 Android \u5e94\u7528\u9879\u76ee\u3002<\/p>\n<p># \u8bbe\u8ba1\u767b\u5f55\u754c\u9762<\/p>\n<p>1. \u5728\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u4e2d\u5c55\u5f00 &#8220;Resources &gt; layout&#8221; \u76ee\u5f55\uff0c\u6253\u5f00 &#8220;Main.axml&#8221; \u6587\u4ef6\u4ee5\u7f16\u8f91 Android \u5e94\u7528\u7684 UI\u3002<\/p>\n<p>2. \u4f7f\u7528\u8bbe\u8ba1\u5668\u6216<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e4%bb%a3%e7%a0%81\/\" title=\"\u4ee3\u7801\" target=\"_blank\">\u4ee3\u7801<\/a><\/span>\u521b\u5efa\u767b\u5f55\u754c\u9762\u3002\u8fd9\u91cc\u5148\u4ee5\u4ee3<\/p>\n<p><figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/i.cdn.yimenapp.com\/2023-04\/07\/10\/28086718104.jpg\" \/><\/figure><\/p>\n<p>\u7801\u4e3a\u4f8b\uff0c\u5c06\u4ee5\u4e0b XML \u4ee3\u7801\u66ff\u6362 &#8220;Main.axml&#8221; \u6587\u4ef6\u7684\u5185\u5bb9\uff1a<\/p>\n<p>&#8220;`xml<\/p>\n<\/p>\n<p>            android:id=&#8221;@+id\/loginRelativeLayout&#8221;<\/p>\n<p>            android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>            android:layout_height=&#8221;match_parent&#8221;<\/p>\n<p>            android:padding=&#8221;20dp&#8221; &gt;<\/p>\n<\/p>\n<p>        android:id=&#8221;@+id\/loginTitle&#8221;<\/p>\n<p>        android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>        android:layout_height=&#8221;wrap_content&#8221;<\/p>\n<p>        android:text=&#8221;\u767b\u5f55&#8221;<\/p>\n<p>        android:textSize=&#8221;24sp&#8221;<\/p>\n<p>        android:gravity=&#8221;center&#8221; \/&gt;<\/p>\n<\/p>\n<p>        android:id=&#8221;@+id\/usernameInput&#8221;<\/p>\n<p>        android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>        android:layout_height=&#8221;wrap_content&#8221;<\/p>\n<p>        android:hint=&#8221;\u7528\u6237\u540d&#8221;<\/p>\n<p>        android:inputType=&#8221;text&#8221;<\/p>\n<p>        android:layout_below=&#8221;@+id\/loginTitle&#8221;<\/p>\n<p>        android:layout_marginTop=&#8221;20dp&#8221; \/&gt;<\/p>\n<\/p>\n<p>        android:id=&#8221;@+id\/passwordInput&#8221;<\/p>\n<p>        android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>        android:layout_height=&#8221;wrap_content&#8221;<\/p>\n<p>        android:hint=&#8221;\u5bc6\u7801&#8221;<\/p>\n<p>        android:inputType=&#8221;textPassword&#8221;<\/p>\n<p>        android:layout_below=&#8221;@+id\/usernameInput&#8221;<\/p>\n<p>        android:layout_marginTop=&#8221;10dp&#8221; \/&gt;<\/p>\n<\/p>\n<p>        android:id=&#8221;@+id\/loginButton&#8221;<\/p>\n<p>        android:layout_width=&#8221;match_parent&#8221;<\/p>\n<p>        android:layout_height=&#8221;wrap_content&#8221;<\/p>\n<p>        android:text=&#8221;\u767b\u5f55&#8221;<\/p>\n<p>        android:layout_below=&#8221;@+id\/passwordInput&#8221;<\/p>\n<p>        android:layout_marginTop=&#8221;20dp&#8221; \/&gt;<\/p>\n<\/p>\n<p><p>&#8220;`<\/p>\n<p>3. \u4fdd\u5b58 &#8220;Main.axml&#8221; \u6587\u4ef6\u3002<\/p>\n<p># \u7f16\u5199\u767b\u5f55<span class=\"wpcom_tag_link\"><a href=\"https:\/\/www.yimenapp.com\/kb-yimen\/tag\/%e9%80%bb%e8%be%91\/\" title=\"\u903b\u8f91\" target=\"_blank\">\u903b\u8f91<\/a><\/span><\/p>\n<p>1. \u5728\u89e3\u51b3\u65b9\u6848\u8d44\u6e90\u7ba1\u7406\u5668\u4e2d\u5c55\u5f00 &#8220;LoginApp&#8221; \u9879\u76ee\uff0c\u6253\u5f00 &#8220;MainActivity.cs&#8221;\u3002<\/p>\n<p>2. \u5728 MainActivity \u7c7b\u4e2d\u627e\u5230 OnCreate(Bundle) \u65b9\u6cd5\uff0c\u5728\u8be5\u65b9\u6cd5\u5185\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u4ee5\u5173\u8054\u5e03\u5c40\u4e2d\u7684\u63a7\u4ef6\uff1a<\/p>\n<p>&#8220;`csharp<\/p>\n<p>Button loginButton = FindViewById<button>(Resource.Id.loginButton);<\/p>\n<p><p>EditText usernameInput = FindViewById(Resource.Id.usernameInput);<\/p>\n<p><p>EditText passwordInput = FindViewById(Resource.Id.passwordInput);<\/p>\n<p><p>&#8220;`<\/p>\n<p>3. \u4e3a\u767b\u5f55\u6309\u94ae\u6dfb\u52a0\u70b9\u51fb\u4e8b\u4ef6\u76d1\u542c\u5668\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<p>&#8220;`csharp<\/p>\n<p>loginButton.Click += delegate<\/p>\n<p>{<\/p>\n<p>    \/\/ \u5904\u7406\u767b\u5f55\u903b\u8f91<\/p>\n<p>};<\/p>\n<p>&#8220;`<\/p>\n<p>4. \u5728\u767b\u5f55\u6309\u94ae\u7684\u70b9\u51fb\u4e8b\u4ef6\u4e2d\uff0c\u6dfb\u52a0\u767b\u5f55\u9a8c\u8bc1\u903b\u8f91\u3002\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u7b80\u5355\u5730\u5b9e\u73b0\u4e00\u4e2a\u9a8c\u8bc1\u6210\u529f\u7684\u6761\u4ef6\u3002\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u5c06\u8fd9\u4e9b\u4fe1\u606f\u4f20\u9012\u7ed9\u670d\u52a1\u5668\u4ee5\u9a8c\u8bc1\u767b\u5f55\u51ed\u636e\u3002<\/p>\n<p>&#8220;`csharp<\/p>\n<p>loginButton.Click += delegate<\/p>\n<p>{<\/p>\n<p>    string username = usernameInput.Text;<\/p>\n<p>    string password = <a href=\"https:\/\/www.anzhuoe.com\/\">\u5b89\u5353app\u5236\u4f5c<\/a>passwordInput.Text;<\/p>\n<\/p>\n<p>    if (username == &#8220;admin&#8221; &amp;&amp; password == &#8220;123456&#8221;)<\/p>\n<p>    {<\/p>\n<p>        \/\/ \u767b\u5f55\u6210\u529f<\/p>\n<p>        Toast.MakeText(this, &#8220;\u767b\u5f55\u6210\u529f\uff01&#8221;, ToastLength.Short).Show();<\/p>\n<p>    }<\/p>\n<p>    else<\/p>\n<p>    {<\/p>\n<p>        \/\/ \u767b\u5f55\u5931\u8d25<\/p>\n<p>        Toast.MakeText(this, &#8220;\u767b\u5f55\u5931\u8d25\uff0c\u8bf7\u68c0\u67e5\u60a8\u7684\u7528\u6237\u540d\u548c\u5bc6\u7801\u3002&#8221;, ToastLength.Short).Show();<\/p>\n<p>    }<\/p>\n<p>};<\/p>\n<p>&#8220;`<\/p>\n<p>5. \u4fdd\u5b58 &#8220;MainActivity.cs&#8221; \u6587\u4ef6\u3002<\/p>\n<p>\u73b0\u5728\u60a8\u5df2\u7ecf\u521b\u5efa\u4e86\u4e00\u4e2a\u7b80\u5355\u7684 Android \u767b\u5f55\u754c\u9762\uff0c\u5e76\u7f16\u5199\u4e86\u76f8\u5e94\u7684\u767b\u5f55\u9a8c\u8bc1\u903b\u8f91\u3002\u63a5\u4e0b\u6765\uff0c\u60a8\u53ef\u4ee5\u6d4b\u8bd5\u8be5\u5e94\u7528\u7a0b\u5e8f\u3002\u53ef\u4ee5\u901a\u8fc7\u8fde\u63a5 Android \u8bbe\u5907\uff0c\u6216\u4f7f\u7528 Android \u6a21\u62df\u5668\u6d4b\u8bd5\u5e94\u7528\u3002\u4e3a\u4e86\u786e\u4fdd\u6d4b\u8bd5\u987a\u7545\uff0c\u8bf7\u786e\u4fdd\u6309\u7167 https:\/\/developer.android.com\/studio\/run\/emulator \u5b98\u65b9\u6587\u6863\u4e2d\u7684\u8bf4\u660e\u8bbe\u7f6e\u597d Android \u6a21\u62df\u5668\u3002<\/p>\n<p>        <\/button><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728Visual Studio 2015\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 Xamarin \u5f00\u53d1\u5de5\u5177\u521b\u5efa\u8de8\u5e73\u53f0\u7684\u79fb\u52a8\u5e94\u7528\u7a0b\u5e8f\uff0c\u5305\u62ec Android \u548c iOS\u3002\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f1a\u6f14\u793a\u5982\u4f55\u5728 Visual Studio 2<\/p>\n","protected":false},"author":19,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[1870,33464,36856,8197,11332],"special":[],"attr":[],"class_list":{"0":"post-42473","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-www","7":"tag-1870","8":"tag-app","10":"tag-8197","11":"tag-11332","12":"entry"},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/42473","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/users\/19"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/comments?post=42473"}],"version-history":[{"count":1,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/42473\/revisions"}],"predecessor-version":[{"id":42483,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/posts\/42473\/revisions\/42483"}],"wp:attachment":[{"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/media?parent=42473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/categories?post=42473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/tags?post=42473"},{"taxonomy":"special","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/special?post=42473"},{"taxonomy":"attr","embeddable":true,"href":"https:\/\/www.yimenapp.com\/kb-yimen\/wp-json\/wp\/v2\/attr?post=42473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}