使用编辑框Edit Text:Button获取从Edit view中输入的值并且输出到title中
XML文件:
<?xml version="1.0" encoding="utf-8"?>Java文件:
package com.example.autocompletetextview;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListAdapter;
import android.widget.TextView;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setTitle("abc");
find_and_modify_text_view();
}
private void find_and_modify_text_view(){
Button button=(Button)findViewById(R.id.buttons);
button.setOnClickListener(get_edit_view_button_listener);
}
private Button.OnClickListener get_edit_view_button_listener=new Button.OnClickListener()
{public void onClick(View v)
{EditText editText=(EditText)findViewById(R.id.edittext);
CharSequence edit_text_value=editText.getText();
setTitle("EditTest的值:"+edit_text_value);
}
};
}