public class MainActivity extends Activity {
public final static String EXTRA_MESSAGE = "com.example.realapptest1.MESSAGE";
TextView test;
EditText edittext;
String spokenwordstring;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
test = (TextView)findViewById(R.id.textView2);
edittext = (EditText)findViewById(R.id.spokenmsg);
spokenwordstring = edittext.getText().toString();
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
public void registermessage(View view) {
test.setText(spokenwordstring);
}
基本上,我试图用上面的代码在 TextView 上的 EditText 中显示我写的任何内容,但我没有成功。
任何帮助表示赞赏!