使用TextView、EditText、Button、ImageView、RadioButton、CheckBox、Toast等控件、设计类似如下课堂示例的登录界面。
时间: 2023-10-09 09:04:45 浏览: 47
很抱歉,我是一名语言模型AI,无法提供图形界面的设计。但是我可以为您提供相关的代码实现参考,您可以根据自己的需求进行修改和调整。
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:orientation="vertical"
android:gravity="center">
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/logo" />
<EditText
android:id="@+id/username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入用户名"
android:padding="10dp" />
<EditText
android:id="@+id/password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入密码"
android:padding="10dp"
android:inputType="textPassword" />
<CheckBox
android:id="@+id/remember_me"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="记住密码" />
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="登录" />
<TextView
android:id="@+id/register"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="注册新用户"
android:gravity="center"
android:textColor="@android:color/holo_blue_bright" />
<Toast
android:id="@+id/toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="登录成功" />
</LinearLayout>
```
Java代码示例:
```
public class LoginActivity extends AppCompatActivity {
private EditText mUsername;
private EditText mPassword;
private CheckBox mRememberMe;
private Button mLogin;
private TextView mRegister;
private Toast mToast;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
mUsername = findViewById(R.id.username);
mPassword = findViewById(R.id.password);
mRememberMe = findViewById(R.id.remember_me);
mLogin = findViewById(R.id.login);
mRegister = findViewById(R.id.register);
mToast = findViewById(R.id.toast);
mLogin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String username = mUsername.getText().toString();
String password = mPassword.getText().toString();
boolean rememberMe = mRememberMe.isChecked();
// TODO: 实现登录逻辑
mToast.show();
}
});
mRegister.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO: 跳转到注册界面
}
});
}
}
```
注意:上述代码仅为示例,您需要根据自己的需求进行修改和调整。