安卓平台开发登录界面代码
时间: 2023-12-06 12:04:27 浏览: 25
好的,以下是一个简单的安卓平台登录界面的代码示例,供你参考:
1. 布局文件 login_layout.xml:
```xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical">
<EditText
android:id="@+id/username_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名" />
<EditText
android:id="@+id/password_edittext"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"
android:inputType="textPassword" />
<Button
android:id="@+id/login_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录" />
<TextView
android:id="@+id/forget_password_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="忘记密码?" />
</LinearLayout>
```
2. LoginActivity.java:
```java
public class LoginActivity extends AppCompatActivity {
private EditText mUsernameEditText;
private EditText mPasswordEditText;
private Button mLoginButton;
private TextView mForgetPasswordTextView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.login_layout);
mUsernameEditText = findViewById(R.id.username_edittext);
mPasswordEditText = findViewById(R.id.password_edittext);
mLoginButton = findViewById(R.id.login_button);
mForgetPasswordTextView = findViewById(R.id.forget_password_textview);
mLoginButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String username = mUsernameEditText.getText().toString();
String password = mPasswordEditText.getText().toString();
// TODO: 处理登录逻辑
}
});
mForgetPasswordTextView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// TODO: 跳转到密码找回页面
}
});
}
}
```
以上是一个简单的安卓平台登录界面的代码示例,其中登录逻辑和密码找回页面的实现需要你自己完成。希望对你有所帮助。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)