写一个基于安卓+java的简洁的登录注册一体的界面
时间: 2024-02-22 07:59:03 浏览: 13
好的,以下是一个基于安卓+Java的简洁的登录注册一体的界面的代码示例:
```
public class LoginActivity extends AppCompatActivity {
private EditText etUsername;
private EditText etPassword;
private Button btnLogin;
private TextView tvRegister;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
etUsername = findViewById(R.id.et_username);
etPassword = findViewById(R.id.et_password);
btnLogin = findViewById(R.id.btn_login);
tvRegister = findViewById(R.id.tv_register);
btnLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 处理登录逻辑
}
});
tvRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// 跳转到注册界面
}
});
}
}
```
XML布局文件:
```
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/et_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="用户名" />
<EditText
android:id="@+id/et_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="密码" />
<Button
android:id="@+id/btn_login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录" />
<TextView
android:id="@+id/tv_register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册新用户" />
</LinearLayout>
```
请注意,这只是一个简单的示例界面,实际应用中可能需要更多的功能和逻辑处理。