How do I add a newline to a TextView in Android?

When I define a TextView in xml, how do I add a new line to it? \n seems not to work. <TextView android:id=”@+id/txtTitlevalue” android:text=”Line1 -\nLine2″ android:layout_width=”54dip” android:layout_height=”fill_parent” android:textSize=”11px” /> 31 Answers 31 Don’t trust the Visual editor. Your code does work in the emu.

Trying to fix line-endings with git filter-branch, but having no luck

I have been bitten by the Windows/Linux line-ending issue with git. It seems, via GitHub, MSysGit, and other sources, that the best solution is to have your local repos set to use linux-style line endings, but set core.autocrlf to true. Unfortunately, I didn’t do this early enough, so now every time I pull changes the … Read more

How to remove line breaks from a file in Java?

How can I replace all line breaks from a string in Java in such a way that will work on Windows and Linux (ie no OS specific problems of carriage return/line feed/new line etc.)? I’ve tried (note readFileAsString is a function that reads a text file into a String): String text = readFileAsString(“textfile.txt”); text.replace(“\n”, “”); … Read more

CSV in Python adding an extra carriage return, on Windows

import csv with open(‘test.csv’, ‘w’) as outfile: writer = csv.writer(outfile, delimiter=”,”, quoting=csv.QUOTE_MINIMAL) writer.writerow([‘hi’, ‘dude’]) writer.writerow([‘hi2’, ‘dude2’]) The above code generates a file, test.csv, with an extra \r at each row, like so: hi,dude\r\r\nhi2,dude2\r\r\n instead of the expected hi,dude\r\nhi2,dude2\r\n Why is this happening, or is this actually the desired behavior? 6 Answers 6