How to save new line from android?

拜拜、爱过 提交于 2019-12-24 11:05:13

问题


I am saving data from edit textbox and getting that to save into pdf....It works fine but if i write text into multiline....it takes as single line...and make pdf file with single line...so how can i get the new line to save into pdf??? Here is code which send data for save data...

Intent i = new Intent(AddText.this,GetText.class);
i.putExtra("data",editText.getText().toString());
startActivity(i);

And in next page i am getting data....

String data = getIntent().getExtras().getString("data");

回答1:


Try this:

Intent i = new Intent(AddText.this,GetText.class);
i.putExtra("data",(editText.getText().toString()).replaceAll("\\n", "\n"));
startActivity(i);



回答2:


use \n whereever you want to use new line. in your code.

for suppose if you want to save pdf with name Android\npdf then you must type like this only and you can get string



来源:https://stackoverflow.com/questions/14473037/how-to-save-new-line-from-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!