Get Value of a Edit Text field

前端 未结 12 921
既然无缘
既然无缘 2020-11-22 07:20

I am learning how to create UI elements. I have created a few EditText input fields. On the click of a Button I want to capture the content typed into that input field.

12条回答
  •  醉话见心
    2020-11-22 07:57

    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
      Button  rtn = (Button)findViewById(R.id.button);
      EditText edit_text   = (EditText)findViewById(R.id.edittext1);
    
        rtn .setOnClickListener(
            new View.OnClickListener()
            {
                public void onClick(View view)
                {
                    Log.v("EditText value=", edit_text.getText().toString());
                }
            });
    }
    

提交回复
热议问题