2013-09-30 23 views
0

我希望用户输入从EditText和他输入的任何他在EditText他按下提交按钮(转到他的输入列表),它将打印在TextView,但如果我想有一个长列表Textview (显示他的输入历史的长列表)...我可以做些什么来让TextView的数量像列表一样增长,因为用户提交更多EditText如何增加TextView的数量?

+0

你想达到什么里面? –

+0

你是否想用多文本显示列表视图!为每个列表项目? – ajey

+0

帮助添加您的代码 –

回答

0

您可以在java类中动态创建TextView,然后添加到您的父视图中。

使用类似如下:

<LinearLayout 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="wrap_content" 
android:id="@+id/info" 
android:layout_height="wrap_content" 
android:orientation="vertical"> 
</LinearLayout> 

那么Java类

View linearLayout = findViewById(R.id.info); 
    LinearLayout linearLayout = (LinearLayout)findViewById(R.id.info) 


    TextView valueTV = new TextView(this); 
    valueTV.setText("hallo hallo"); 
    valueTV.setId(5); 
    valueTV.setLayoutParams(new LayoutParams(
      LayoutParams.FILL_PARENT, 
      LayoutParams.WRAP_CONTENT)); 

    linearLayout.addView(valueTV); 
+0

在运行时创建新的textview并添加到LinearLayout – Swetank