我的问题的屏幕截图在此链接中提供:
https://goo.gl/photos/24BTZMX1DxLXnm5J9
我正在使用两个单独的活动,例如活动A和活动B.在活动A中,我已合并了一个编辑文本字段。如果用户在双引号内输入一些字符,我只需要显示双引号内提到的字符。
例如,如果edittext中的用户输入类似于
价值=“欢迎来到餐厅”
必须在活动B中显示欢迎来到餐厅,忽略值=
请帮我解决这个问题。提前致谢 拯救我们的灵魂。
答案 0 :(得分:1)
试试这个(记住你的意思我想单独用双引号显示内容。)
String example="Value = \"Welcome to the restaurant\""; //replace with EditText value
int firstQuoteIndex=example.indexOf("\"")+1;
int lastQuoteIndex=example.lastIndexOf("\"");
String result=example.substring(firstQuoteIndex, lastQuoteIndex);
答案 1 :(得分:0)
String usertext= edittext.getText().toString();
2
Intent i =new Intent(A.this,B.class);
i.putExtra("uservalue",usertext);
startActivity(i);
3。 在B活动
String valueretrn=getIntent().getExtra().getString("uservalue");
textview.setText(valueretrn);