2014-02-07 54 views
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); 

       } 

結果是:所以它到行的末尾,嘗試適合「22」,你可以看到截圖的結果。在水平LinearLayout上膨脹多個TextViews

當然,顯示數字不是我的目標,我想從數組中添加字符串,所以它看起來像普通文本 - 當一行結束時,文本應該從下一行開始。

我該如何實現這一目標 - 因此22號線將從2號線開始?

enter image description here

所有的
+0

使用水平滾動型 –

+0

我不知道你是如何與這樣的想法來了,但不是新的充氣你textViews可以添加新的文本到舊的,像'textView.setText(textView.getText()。toString()+「new text」);' – Ayoub

+0

我真的很期待這樣的事情。每當你問問題 - 有人說一些不能解決你的問題的東西。我需要一組TextView來爲其中的一些設置onClickListeners。這是否回答你的問題?現在我需要我的答案。 – user2976267

回答

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> 
+0

我在問充氣TextView – user2976267

+0

在這裏粘貼你的代碼 –

+0

意味着你想要添加的運行時間 –

1

首先,你對論壇用戶的態度是很煩人的。像「我知道你不會解決我的問題」或「請閱讀我的問題!」這樣的句子。應該避免,因爲在這裏你可以找到試圖幫助你的人,而不是爲了給你提供服務而付費的人。

這麼說,我想爲您解決問題的唯一方法是通過編程讓你的屏幕的寬度和評估多少TextViews可以適合在屏幕上,然後使用嵌套的LinearLayout(左外側垂直和內部水平)