今天主要学了怎么传值和登录界面的制作
登录界面XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical"
>
<EditText
android:id="@+id/username"
android:layout_width="200dp"
android:layout_height="50dp"
android:drawableLeft="@drawable/baseline_add_ic_call_24"
android:hint="用户名"
android:inputType="phone"
android:textColorHint="@color/black" />
<EditText
android:id="@+id/password"
android:layout_width="200dp"
android:layout_height="50dp"
android:orientation="vertical"
android:drawableLeft="@drawable/baseline_5g_24"
android:drawablePadding="20dp"
android:hint="密码"
android:inputType="textPassword"
android:paddingLeft="10dp"
android:textColorHint="@color/black" />
<Button
android:id="@+id/bintt"
android:text="登录"
android:layout_width="100dp"
android:layout_height="40dp"
/>
</LinearLayout>
Java
private EditText username;
private EditText password;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button bin=findViewById(R.id.bintt);
username=findViewById(R.id.username);
password=findViewById(R.id.password);
bin.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
String name=username.getText().toString();
String pwd=password.getText().toString();
Log.e("name:",name);
Log.e("password",pwd);
}
});
}