0
我有一些这样的代码:中添加许多线性布局滚动视图
l = new LinearLayout(this);
l.setOrientation(LinearLayout.VERTICAL);
scrollView.addView(l);
TextView ch = new TextView(this);
Button ndda = new Button(this);
ndda.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
Button nddb = new Button(this);
Button nddc = new Button(this);
Button nddd = new Button(this);
ch.setText("ndch");
ndda.setText("da");
nddb.setText("db");
nddc.setText("dc");
nddd.setText("dd");
l.addView(ch);
l.addView(ndda);
l.addView(nddb);
l.addView(nddc);
l.addView(nddd);
现在我想添加大量的线性布局(可能是15)在滚动视图。我怎样才能做到这一点与短代码?并在每个线性布局的按钮我想setOnClickListener对他们做一些事情。我尝试使用listview来做到这一点,但它滚动时一直刷新,我无法禁用刷新。我是一个新手,所以请给我看看细节。感谢所有
您可能想要使用ListView来代替。 –
你只能有一个ScrollView的直接子元素。如果你想这样做,那么将它添加到主线性布局中。 – Rohit5k2
是@MikeM。是对的。从我能从这个问题中得到的结果,我觉得最好使用ListView或GridView。 – Rohit5k2