我读了很多文章,但都说
使用正则表达式的字符串
让我举例说明。
Button , EditText TextView . 我想把课文从 EditView 把它放在盒子里 文本框 我有两种方法,我的问题是它们之间有什么区别。
Button
EditText
TextView
EditView
文本框
所有这些代码都进入ONCLICK侦听器。
Scanner sc = new Scanner(editText.getText().toString()); String a = sc.next(); txv.setText(a);
txv.setText(editText.getText().toString());
你不应该在这里使用Scanner,你应该使用StringTokenizer,或者只是 split("\\s+")[0]
split("\\s+")[0]
sc.next() 将扫描器输入字符串的第一个连续非空白字符读入变量 a ,设置为下一个文本视图。
sc.next()
a
例如
Scanner sc = new Scanner("hello world"); String s = sc.next(); // == "hello"