日日爱影视_日本一区二区三区日本免费_大香焦伊人在钱8_欧美一级夜夜爽 - 日韩三级视频在线观看

當前位置:首頁 ? 做APP ? 正文

vs2015開發安卓app登錄界面怎么做?

在Visual Studio 2015中,可以使用 Xamarin 開發工具創建跨平臺的移動應用程序,包括 Android 和 iOS。在本教程中,我們將會演示如何在 Visua安卓APP開發l Studio 2015 內使用 Xamarin 開發 Android 應用程序,并為該應用創建一個登錄界面。

# 準備工作

1. 安裝 Visual Studio 2015(Community、Professional 或 Enterprise版本均可)。

2. 安裝 Xamarin。通常在 Visual Studio 安裝過程中可以選擇 Xamarin 作為一個組件。如果沒有安裝 Xamarin,可以在 https://www.xamarin.com 實現下載并安裝。

# 創建 Android 項目

1. 打開 Visual Studio 2015,選擇 “新建項目…”。

2. 在模板中選擇 “Installed > Templates > Visual C# > Android > Blank App(Android)”。

3. 為項目命名,例如 “LoginApp”,然后點擊 “確定”。

Visual Studio 將會創建一個新的基于 Xamarin 的 Android 應用項目。

# 設計登錄界面

1. 在解決方案資源管理器中展開 “Resources > layout” 目錄,打開 “Main.axml” 文件以編輯 Android 應用的 UI。

2. 使用設計器或代碼創建登錄界面。這里先以代

碼為例,將以下 XML 代碼替換 “Main.axml” 文件的內容:

“`xml

android:id=”@+id/loginRelativeLayout”

android:layout_width=”match_parent”

android:layout_height=”match_parent”

android:padding=”20dp” >

android:id=”@+id/loginTitle”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:text=”登錄”

android:textSize=”24sp”

android:gravity=”center” />

android:id=”@+id/usernameInput”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:hint=”用戶名”

android:inputType=”text”

android:layout_below=”@+id/loginTitle”

android:layout_marginTop=”20dp” />

android:id=”@+id/passwordInput”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:hint=”密碼”

android:inputType=”textPassword”

android:layout_below=”@+id/usernameInput”

android:layout_marginTop=”10dp” />

android:id=”@+id/loginButton”

android:layout_width=”match_parent”

android:layout_height=”wrap_content”

android:text=”登錄”

android:layout_below=”@+id/passwordInput”

android:layout_marginTop=”20dp” />

“`

3. 保存 “Main.axml” 文件。

# 編寫登錄邏輯

1. 在解決方案資源管理器中展開 “LoginApp” 項目,打開 “MainActivity.cs”。

2. 在 MainActivity 類中找到 OnCreate(Bundle) 方法,在該方法內添加以下代碼,以關聯布局中的控件:

“`csharp

Button loginButton = FindViewById

未經允許不得轉載:http://www.glwnet.com/智電網絡 ? vs2015開發安卓app登錄界面怎么做?

相關推薦

推薦欄目