1

我有一个扩展类View。我想以ScrollView编程方式将其添加到。我可以将它添加到 aLinearLayout但对 a 没有成功ScrollView。是什么赋予了?

sv = (ScrollView)findViewById(R.id.sv);

myview = new MyViewClass(this);
myview.setLayoutParams(new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

sv.addView(myview);
4

2 回答 2

1

您可以将 View 添加到 ScrollView if its the only view in the ScrollView

否则你会得到ScrollView can have only 1 direct child异常。

将多个视图添加到 ScrollView。首先在ScrollView中添加一个Linear或者RelativeLayout,然后在这个Layout中添加Views。

于 2012-08-24T08:54:21.687 回答
0
jsonUserInfo = actionObject.getUserInfoID(urlsId).getJSONArray("data").getJSONObject(i);
ModeUser userinf=new ModeUser();
userinf.Male=jsonUserInfo.getString("sex");
userinf.userName=jsonUserInfo.getString("first_name");
userinf.UserLastName=jsonUserInfo.getString("last_name");
UserInfoDatInList.add(userinf);
于 2013-03-28T14:31:54.870 回答