scrollview = (ScrollView)findViewById(R.id.detailedScrollView);
for (Quotation quotation : object.quotes){
TextView quote = new TextView(this);
quote.setText(quotation.getQuote());
quote.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
scrollview.addView(quote);
}
假设有三个引号,那么我想要三个textView。但是,上面的代码崩溃了我的应用程序。任何明显的错误?这里是我得到的错误:在for循环中添加textViews
11-06 17:35:53.214: E/AndroidRuntime(1430): java.lang.IllegalStateException: ScrollView can host only one direct child
什么的logcat的说?你得到的错误是什么? –
11-06 17:35:53.214:E/AndroidRuntime(1430):java.lang.IllegalStateException:ScrollView只能托管一个直接孩子 啊scrollview只能有一个孩子?我想我需要将所有内容放入linearLayout中,然后放入scrollview中? – Adam