How to Fill an Activity with text stored in /raw
<p>I have an app for a project. my idea was to create a 3 tab app, in each tab there are several buttons representing a topic. each topic has a txt file containing some information I wish to display in an activity that is opened when clicking a particular button. so the same activity is opened, but the text filling it will depend on the button pressed.</p>

<p>I have everything except the ability to display the text, currently stored in /raw as a txt.</p>

<p>I'm looking at input readers and txt vs xml (former seems easier), and I'm still struggling.</p>

<p>Even if I manage to get it to display a particular txt file, I don't know how to get it to work dependant on which button is pressed.</p>

<p>The content holding activity has a textview which I planned to fill with text from the .txt file.</p>

<p>Any help would be appreciated.</p>

<p>I get a syntax error on that catch. spent the last 15 minutes trying to figure it out</p>

<p>EDIT</p>

<p><strong>activity with buttons in it,</strong> </p>

<pre><code>public class MartialTab extends Activity {
Button btn1, btn2;
String choice;

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    TextView textview = new TextView(this);
    textview.setText("This is the martial arts tab");
    setContentView(textview);

    setContentView(R.layout.martial_tab);//takes layout from martial_tab.xml

    btn1 = (Button) findViewById(R.id.kickboxingButton);//instantiates a button called btn1 one from the xml
    btn1.setOnClickListener( new OnClickListener() {
        public void onClick(View v) {
            kickBoxingBut(v, choice);
        }//calls the method
    });//end of method

    btn2 = (Button) findViewById(R.id.grecoroman);//instantiates a button called btn1 one from the xml
    btn2.setOnClickListener( new OnClickListener() {
        public void onClick(View v) {
            grecoromanBut(v);
        }//calls the method
    });//end of method


}



  // private void kickBoxingBut() {//button1 method
    //new AlertDialog.Builder(this).setTitle("AlertNotification").setMessage(
       // "This is an Alert Dialogue Toast").setNeutralButton( "Click Me!", null).show(); 
    //creates an alert notification with the above text
  //}
    public   String kickBoxingBut(View view, String s) { 
        startActivity(new Intent(this, ContentHolder.class));
        this.choice = "kick";

        return choice;

    }

    public void grecoromanBut(View view) { 
        startActivity(new Intent(this, ContentHolder.class));
    }       
}
</code></pre>

<p><strong>activity that holds the info</strong></p>

<pre><code>     public class ContentHolder extends Activity  {



    public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    Context m_Context = getApplicationContext();

    TextView textview = new TextView(this);
    textview.setText("This is the content view");
    setContentView(textview);

    Bundle extras = getIntent().getExtras(); 
    if(extras !=null) {
    String value = extras.getString("choice");
    }



    InputStream input;

    try {
        input = m_Context.getAssets().open("choice");

    DataInputStream in = new DataInputStream(input);
    BufferedReader br = new BufferedReader(new InputStreamReader(in));
    String strLine;
    // Read File Line By Line
    while ((strLine = br.readLine()) != null) {
        // Print the content on the console
        System.out.println(strLine);
        textview.setText(strLine);
    }
    // Close the input stream
    in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    }
    //setContentView(R.layout.main);

   }
</code></pre>

<p>This setContentView is a problem. As above doesn't work as it expects a return type. changing it to ContentHolder doesn't work either.</p>
