package com.example.android0908;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.Toast;
import javax.microedition.khronos.egl.EGLDisplay;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.llinearlayout92902);
initWidget();
}
private void initWidget()
{
Toast toast;
toast = Toast.makeText(this,"helloworld",Toast.LENGTH_LONG);
toast.show();
ImageButton but;
but=(ImageButton) findViewById(R.id.but1);
but.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
EditText et1;
et1 = (EditText)findViewById(R.id.et1);
String mima = et1.getText().toString();
EditText et2;
et2 = (EditText)findViewById(R.id.et2);
et2.setText(mima);
}
});
}
}
<?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:background="#00B7FF">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et1"
android:layout_width="256dp"
android:layout_height="wrap_content"
android:hint="请输入密码:"
android:password="true" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<EditText
android:id="@+id/et2"
android:layout_width="258dp"
android:layout_height="wrap_content"
android:hint="您输入的密码为" />
<ImageButton
android:id="@+id/but1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#26FF00"
android:src="@drawable/eyes"
android:textSize="10dp" />
</LinearLayout>
</LinearLayout>
?
|