simple question what do i need to add to this code so that when the button is pressed it replaces the text view with one of the strings from the array list?
package com.
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 main extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
TextView tx = (TextView) findViewById(R.id.textView2);
tx.setText("Hello");
}
});
}
}
-----------------------------------------------------
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, main!</string>
<string name="app_name">Ihavenever</string>
<string-array
name="list">
<item>@string/girl</item>
<item>@string/boy</item>
<item>@string/man</item>
<item>@string/women</item>
<item>@string/dog</item>
<item>@string/cat</item>
</string-array>
</resources>
so in a nutshell the app launches there is a button at the bottom once pushed it puts one of the items in the string array in the textview in the middle of screen and when you push it again it gives you another one and another one till there is none left and then restarts from the first one ?