Перенос строки в java

Рейтинг: 1Ответов: 1Опубликовано: 21.10.2014

Пишу приложение для android, вставил гугл карты, но ни как не могу понять, как делать перенос строки, ни \n \n\r \\n - ничего не помогает, на карте всё равно всё пишется в одну строчку. Как сделать перенос наподобие <br>?

mMap.addMarker(new MarkerOptions().position(new LatLng(59.961159, 30.291961)).title("Название точки").snippet("Станция метро \"Чкаловская\", Устройство расположено в вестибюле станции метро рядом со входом.\n" +
    "Часы работы\n" +
    "\n" +
    "Пн-Вс: 6:00 - 0:00")  );

Обновление

Спасибо, но он почему-то у вас ругается на xml файл, по идее же должно быть так?

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/map"
tools:context="com.example.client6.tetrapolis.MapsActivity2"
android:name="com.google.android.gms.maps.SupportMapFragment"/>

И дальше ваш xml

Error:(9) Error parsing XML: junk after document element

Ответы

▲ 2

Необходимо сделать кастомное информационное окно

    mMap.setInfoWindowAdapter(new Yourcustominfowindowadpater());

class Yourcustominfowindowadpater implements InfoWindowAdapter {
        private final View mymarkerview;

        Yourcustominfowindowadpater() {
            mymarkerview = getActivity().getLayoutInflater().inflate(
                R.layout.view_info_window, null);
    }

    public View getInfoWindow(Marker marker) {
        render(marker, mymarkerview);
        ((TextView) mymarkerview.findViewById(R.id.title)).setText(marker
                .getTitle());
        ((TextView) mymarkerview.findViewById(R.id.snippet)).setText(marker
                .getSnippet());
        return mymarkerview;
    }

    public View getInfoContents(Marker marker) {
        ((TextView) mymarkerview.findViewById(R.id.title)).setText(marker
                .getTitle());
        ((TextView) mymarkerview.findViewById(R.id.snippet)).setText(marker
                .getSnippet());
        return null;
    }

    private void render(Marker marker, View view) {
    }
}

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:background="@drawable/frame_white">

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical">
    <TextView
        android:id="@+id/title"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="12dp"
        android:maxLines="1"
        android:ellipsize="end"
        android:padding="5dp"
        android:textStyle="bold"/>
    <TextView
        android:id="@+id/snippet"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:maxLines="3"
        android:ellipsize="end"
        android:padding="5dp"
        android:textSize="10dp"/>
</LinearLayout>

</LinearLayout>