button_1.setOnClickListener(new View.OnClickListener() { android
@Overrideide
public void onClick(View v) {spa
String button_1_content=button_1 .getText().toString();字符串
//得到按键的内容,读取的数据来自android:text get
editText=(EditText)findViewById(R.id.editText);it
textContent=editText .getText().toString();io
text=textContent +button_1_content;List
/* 数据
*这里文本框的输出内容必须是textContent+button_1_content di
*若是只把button_1_content赋值给text,
*那么在按下按键1时会清除以前文本框中输入的内容,只显示一个数字1
**/
editText.setText(text );
editText.setSelection(text .length());
/*
*setSelection()的做用是定位光标
*该句话的意思是光标的位置为当前字符串长度的后一个位置
*注意:不能将光标的位置定位在当前长度的后面,即
*editText.setSelection(text.length()+1),这样会闪退
**/