简单登录界面的制作

    <EditText
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:id="@+id/edx_1"
        android:textSize="16sp"
        android:textColor="#FFAD33"
        android:hint="用户名"
        android:inputType="number"
        android:background="@drawable/miaoban"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:drawableLeft="@drawable/user"
        android:drawablePadding="5dp"
        android:maxLines="1"

        />
    <EditText
        android:layout_width="match_parent"
        android:layout_height="80dp"
        android:id="@+id/edx_2"
        android:textSize="16sp"
        android:textColor="#FFAD33"
        android:inputType="textPassword"
        android:hint="密码"
        android:layout_below="@+id/edx_1"
        android:background="@drawable/miaoban"
        android:layout_marginTop="15dp"
        android:paddingLeft="15dp"
        android:paddingRight="15dp"
        android:drawableLeft="@drawable/password"
        android:drawablePadding="5dp"
        android:maxLines="1"
        />

    <Button
        android:id="@+id/login"
        android:layout_width="match_parent"
        android:layout_height="50dp"
        android:layout_below="@id/edx_2"
        android:background="@drawable/miaoban"
        android:layout_marginTop="30dp"
        android:text="登录"
        android:textSize="20dp"

        />
 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_button1);
        button = (Button)findViewById(R.id.login);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Toast.makeText(Button1.this,"登陆成功",Toast.LENGTH_SHORT).show();
            }
        });

        editText = (EditText)findViewById(R.id.edx_1);
        editText.addTextChangedListener(new TextWatcher() {
            @Override
            public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {

            }

            @Override
            public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
                Log.d("edittext",charSequence.toString());
            }

            @Override
            public void afterTextChanged(Editable editable) {

            }
        });
    }

 

posted @ 2022-02-13 20:44  软工小蜗牛  阅读(176)  评论(0编辑  收藏  举报