I've just entered the Android World, I'm using Android Studio and a Book to get started, so after have read some chapters I want to make some practice of what I've just read.
I'd like to create a simple app that asks you for a word and a number and after clicking a button you get a brand new activity with the word you submitted, displayed the exact amount you said before.
Example: Hello, 4 = Hello Hello Hello Hello (vertically)
So I did create this method in the main activity:
public void submit(){
EditText Edtword = (EditText) findViewById(R.id.text);
EditText Edtnum = (EditText) findViewById(R.id.number);
String word = Edtword.getText().toString();
int num = Integer.parseInt(Edtnum.getText().toString());
Intent intent = new Intent(this, display.class);
intent.putExtra(display.EXTRA_MESSAGE, word);
intent.putExtra("number", (int)num);
startActivity(intent);
}
And this second Activity launched by a button:
public class display extends AppCompatActivity {
public static final String EXTRA_MESSAGE = "word";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_display);
Intent intent = getIntent();
String word = intent.getStringExtra(EXTRA_MESSAGE);
int num = intent.getIntExtra("number", 0);
}
What should I add in the 2nd activity in order to create programmatically those TextViews? I tried with loops but couldn't go successful.
Thanks