neo
neo

Reputation: 1404

How to show exact amount of Views?

Let I have some number n. It can be equal to any integer number ranged between 2 and 15,for example. And according to this number, I need to show n TextView's(orButtons). I need this concept for creating kind of 4 pic 1 word quiz game. As you know, in this game , if secret word is banana,then app create 6 places for each letter. And my question is what kind of concepts to use in order to solve this problem? My idea for solution was following: creating some view and add to this view a TextView n times. But I don't think that it is right way to do that. Can you tell me what I have to use in order to achieve my goal?

Upvotes: 1

Views: 73

Answers (1)

Lew  Perren
Lew Perren

Reputation: 1239

Loads of ways to achieve this:

  1. You couid just create the placeholders you want in an XML Layout, I would of thought EditText with maxLength=1 and then use .setVisibility to show the ones you need depending on question;

  2. You could use a loop to generate the number of elements you want. See here for code example

Upvotes: 2

Related Questions