Android实现EditText文本的输入,通过点击按钮,获取输入的内容

               

 

ellipsize="marquee" 设置滚动

marquee_forever 一直滚动   

 

scrollHorizontally="true" 设置为水平滚动

focusable 聚焦

xml 文件        



















 

 styel 文件



 

Java 文件

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {
    private Button button;
    private TextView textView_quedin;
    private EditText editText_mima, editText_name, editText_yx, editText_sj;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        button = (Button) findViewById(R.id.Button_quedin);
        this.editText_mima = (EditText) findViewById(R.id.editText_mima);
        this.editText_sj = (EditText) findViewById(R.id.editText_sj);
        this.editText_name = (EditText) findViewById(R.id.editText_name);
        this.editText_yx = (EditText) findViewById(R.id.editText_yx);


        textView_quedin = (TextView) findViewById(R.id.textView_quedin);
        button.setOnClickListener(new View.OnClickListener() {//注册监听
            @Override //监听点击事件
            public void onClick(View v) {
                String name = editText_name.getText().toString();
                String mima=editText_mima.getText().toString();
                String sj=editText_sj.getText().toString();
                String yx=editText_yx.getText().toString();

                textView_quedin.setText("用户名:"+name+"\n"+"密码:"+mima+"\n"+"手机号:"+sj+"\n"+"邮箱:"+yx);
 

            }        });    }}//

 
setText();

设置其内容

editText_name.getText().toString();

获得其内容Android实现EditText文本的输入,通过点击按钮,获取输入的内容_第1张图片Android实现EditText文本的输入,通过点击按钮,获取输入的内容_第2张图片

你可能感兴趣的:(Android)