【问题标题】:Android: Start a new line in a string after full stop in javaAndroid:在java中句号后在字符串中开始新行
【发布时间】:2021-01-19 10:43:42
【问题描述】:

我正在使用以下代码尝试在句子结尾后开始一个新行,例如“2.Put the turkey”将开始一个新行。但这不会发生。我做错了什么?

“1.制作墨西哥调味料,将材料混合在一个碗中。2.将火鸡肉末和墨西哥调味料放入一个大碗中,用手搅拌均匀。3.加热一半的橄榄油煎炸用大火平底锅,将洋葱、葱和辣椒煮 3 分钟。加入少许盐和胡椒粉。将蔬菜从锅中取出并放在一边。

    method.replaceAll("\\.\\s?", "\\.\n");
    methodText = findViewById(R.id.methodText);
    methodText.setText(method);

【问题讨论】:

标签: java android


【解决方案1】:

试试这个....

String method="1.To make the Mexican seasoning, mix the ingredients together in a bowl. 2.Put the turkey mince and Mexican seasoning into a large bowl and mix well with your hands. 3.Heat half the olive oil in a frying pan over a high heat and cook the onions, spring onions and peppers for 3 minutes. Add a pinch of salt and pepper. Remove the vegetables from the pan and set aside.";
        String m=method.replaceAll("\\. ", ".\n");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-18
    • 2012-12-28
    • 2018-02-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多