string display new line with n in android app

Solutions on MaxInterview for string display new line with n in android app by the best coders in the world

showing results for - "string display new line with n in android app"
Ivan
23 Oct 2019
1
2package com.cfsuman.me.myapplication5;
3
4import android.support.v7.app.ActionBarActivity;
5import android.os.Bundle;
6import android.view.Menu;
7import android.view.MenuItem;
8import android.view.View;
9import android.text.Html;
10import android.widget.TextView;
11
12
13public class MainActivity extends ActionBarActivity {
14
15    @Override
16    protected void onCreate(Bundle savedInstanceState) {
17        super.onCreate(savedInstanceState);
18        setContentView(R.layout.activity_main);
19    }
20
21    public void perform_action(View v)
22    {
23        TextView tv1 = (TextView) findViewById(R.id.text_view1);
24        //define multiline by \n line separator
25        tv1.setText("Line number 1 \nLine number 2 \nLine number 3");
26
27        TextView tv2 = (TextView) findViewById(R.id.text_view2);
28        tv2.setText("Line number 1");
29        //define new line by append android system line separator
30        tv2.append(System.getProperty("line.separator"));
31        tv2.append("Line number 2");
32
33        TextView tv3 = (TextView) findViewById(R.id.text_view3);
34        String str = "Line number 1"
35                + System.getProperty("line.separator")
36                + "Line number 2";
37        //define new line by android system line separator
38        tv3.setText(str);
39
40        TextView tv4 = (TextView) findViewById(R.id.text_view4);
41        //define new line by html <br />tag
42        String str2 = "Line number 1 <br /> Line number 2";
43        //need to import android.text.Html class
44        tv4.setText(Html.fromHtml(str2));
45
46        TextView tv5 = (TextView) findViewById(R.id.text_view5);
47        tv5.setText(R.string.Multiline_Text_By_N);
48    }
49
50    @Override
51    public boolean onCreateOptionsMenu(Menu menu) {
52        // Inflate the menu; this adds items to the action bar if it is present.
53        getMenuInflater().inflate(R.menu.menu_main, menu);
54        return true;
55    }
56
57    @Override
58    public boolean onOptionsItemSelected(MenuItem item) {
59        // Handle action bar item clicks here. The action bar will
60        // automatically handle clicks on the Home/Up button, so long
61        // as you specify a parent activity in AndroidManifest.xml.
62        int id = item.getItemId();
63
64        //noinspection SimplifiableIfStatement
65        if (id == R.id.action_settings) {
66            return true;
67        }
68
69        return super.onOptionsItemSelected(item);
70    }
71}
72
queries leading to this page
how to add new line in string in androidnext line in android stingadd line break in string androidandroid add new line to stringadd newline to string xml javanew line strings xml androidandroid how to add new line for stringandroid studio new line 2fnhow to add new line in textview androidnew line in android values stringsnew line in string file androidadd new line in string android 5cadd new line in string androidandroid string res new lineandrodi append string in a new linenew line android stringmake element on new line android xmlend line in strings xmlhow to indicate new line in text androidhow to use new line in string using android studiohow to add new line in string androidhow to add line break to 3cstring 3e xmlandroid studio new line in stringnewlines in string androidnewline in android stringsnext line in string android xmlnew line in string xml androidhow to do n in string android studionew line in strings xml androidshow to next line in stings xml in andriod studioadd new line in android stingandroid new line in stringnew line in android stringnew line in strings androidandroid strings new linenew line in androidhow to add new line in android studio stringhow to display new line in textview androidandroid how to add new linenext line string androidandroid string next linenext line in string androidandroid string new linenext line in string android studioadd line break android string xmlnext line statement in string android 5cn in strings android studioadd new line android studioandroid next line in stringnext line in text java androidandroid newline in string 40string with newline androidnew line in android steandroid strings with new linenew line in kotlin string androidnew line character in android strings xmlnewline in text string androidstring display new line with n in android app