Agregar una vista a ScrollView

Tengo una clase que se extiende View. I want to add it to a ScrollView programmatically. I'm able to add it to a LinearLayout but have no success with a ScrollView. ¿Lo que da?

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);

preguntado el 24 de agosto de 12 a las 02:08

Are you calling setContentView(sv); ? -

no, I'm calling setContentView(R.layout.main) which contains the scrollview -

2 Respuestas

You can add your View to the ScrollView if its the only view in the ScrollView.

De lo contrario obtendrá ScrollView can have only 1 direct child excepción.

To add multiple Views to a ScrollView. First add a Linear or Relative Layout in the ScrollView and then add Views to this Layout.

Respondido 27 ago 12, 07:08

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);

respondido 28 mar '13, 14:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.