0
for(int i=0;i<45;i++){
                    textView[i]=new TextView(context);
                    iInflateGoesHere.addView(stringArray[i]);//iInflateGoesHere is a horizontal LinearLayout
                    textView[i].setText(" "+i);

                }

the result is : so it goes to the end of the line , tries to fit "22" and you can see the result on the screenshot.

of course, showing numbers is not my aim, I want to add strings from array so it will look like normal text - when one line ends, text should go from the start of next line.

How can I acheive that - so number 22 will go from the start of line 2 ?

enter image description here

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
Vlad Alexeev
  • 2,072
  • 6
  • 29
  • 59
  • use horizontal scrollview – Biraj Zalavadia Feb 07 '14 at 11:00
  • I'm not sure how you came up with this idea, but instead of inflating new textViews you could add the new text to the old one, like `textView.setText(textView.getText().toString() + "new text");` – Ayoub Feb 07 '14 at 11:55
  • I really expected something like this. Whenever you ask question - someone say something that doesn't solve your issue. I need an array of TextViews to set onClickListeners for some of them. Does that answer your question? Now I need an answer to mine. – Vlad Alexeev Feb 07 '14 at 12:32
  • You can use HorizontalScrollView to add large number of views horizontally. – Khawar Raza Feb 07 '14 at 13:44
  • I described exactly what I need in my question. Read the last line of my question,please! – Vlad Alexeev Feb 07 '14 at 14:04

3 Answers3

1

First of all, your attitude towards forum users is very annoying. Sentences like "I knew you wouldn't solve my question" or "please read my question!" should be avoided, as here you can find people trying to help you, not people paid to give you services.

Saying that, I think the only way to solve your issue is to programmatically get the width of your screen and evaluate how many TextViews can fit on the screen, then using nested LinearLayout (the outer vertical and the inner horizontal)

sthor69
  • 638
  • 1
  • 10
  • 25
1

If you're still looking for the solution, think this might help https://github.com/ApmeM/android-flowlayout

0
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="fill_parent"
    android:layout_height="fill_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" >

    <TextView
        android:id="@+id/mylayout"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="asdfffffffdfaffdffffsffdsffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" >
    </TextView>

</LinearLayout>
Bhanu Sharma
  • 5,135
  • 2
  • 24
  • 49