title: Android SDK: Show one line at a time and proceed with onClick
body: <p>I'm new to Java and the Android SDK but I'm willing to learn. What I want to do is to build an app that take a sentence, or a generic string and displays only one line of text, this is already coded. But I want to do is to proceed to the "next" line by clicking a button called something like "Proceed". So in short it is just offers you to read a little amount of text at a time and proceed b clicking a button.</p>
  
  <p>This is how far I've got:</p>
  
  <p>activity_main.xml</p>
  
  <pre><code>&lt;RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
      android:paddingLeft="@dimen/activity_horizontal_margin"
      android:paddingRight="@dimen/activity_horizontal_margin"
      android:paddingTop="@dimen/activity_vertical_margin"
      tools:context=".DisplayMessageActivity"
      android:orientation="horizontal" &gt;
  
      &lt;TextView
          android:id="@+id/text_box"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:textSize="50sp"
          android:maxLines="1" /&gt;
  
      &lt;Button
          android:id="@+id/next_button"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_centerHorizontal="true"
          android:layout_centerVertical="true"
          android:text="@string/next"
          android:onClick="nextLine"
          android:textSize="15sp" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>MainActivity.java:</p>
  
  <pre><code>package com.xxx.xxx.xxx;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
      String s = "Iphone swag fanny pack, try-hard master cleanse pop-up elit deserunt vinyl. Odio mustache hoodie YOLO fap. Vegan godard labore tempor. Farm-to-table aute craft beer, YOLO bicycle rights artisan semiotics. Cosby sweater readymade eiusmod consectetur fap stumptown. Cliche keytar accusamus blue bottle, wayfarers locavore selfies elit aliqua chillwave lo-fi helvetica enim. Irony tofu blog, fap pickled pariatur odio wolf cliche vice sint pitchfork eiusmod cosby sweater polaroid.";
      final String[] words = s.split("\\s+");
  
      Button b = (Button) findViewById(R.id.next_button);
  
      b.setOnClickListener(new OnClickListener() {
         @Override
         public void onClick(View v) {
             TextView tx = (TextView) findViewById(R.id.text_box);
             StringBuilder builder = new StringBuilder();
             for (String s : words){
               builder.append(s+" ");
             tx.setText(builder.toString());
         }
      }});
  
  }}
  </code></pre>
  
  <p>As of now no text is loaded into the textView and the button loads all of the text at once when clicked on with no support to "reclick" it.</p>
  
  <p>Any ideas?</p>
  
  <p>Best regards,</p>
  
  <p><strong>Update:</strong>
  I've made a counter to account for which word should be printed on the screen. I have another question: how do I go about to make tre words (or any number of words) to show instead of just one? I tried to fiddle with indexranges but I can't seem to get the hang of it. This is how my MainActivity.java looks like now:</p>
  
  <pre><code>package com.xxx.xxx.xxx;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
      int counter;
      String s = "Iphone swag fanny pack, try-hard master cleanse pop-up elit deserunt vinyl. Odio mustache hoodie YOLO fap. Vegan godard labore tempor. Farm-to-table aute craft beer, YOLO bicycle rights artisan semiotics. Cosby sweater readymade eiusmod consectetur fap stumptown. Cliche keytar accusamus blue bottle, wayfarers locavore selfies elit aliqua chillwave lo-fi helvetica enim. Irony tofu blog, fap pickled pariatur odio wolf cliche vice sint pitchfork eiusmod cosby sweater polaroid.";
      final String[] words = s.split("\\s+");
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          final TextView tx = (TextView) findViewById(R.id.text_box);
          counter = 0;
          tx.setText(words[counter]);
  
      Button b = (Button) findViewById(R.id.next_button);
  
      b.setOnClickListener(new OnClickListener() {
         @Override
         public void onClick(View v) {
             counter++;
             tx.setText(words[counter]);
         }
      });
  
  }}
  </code></pre>