Agregar una vista a ScrollView
Frecuentes
Visto 120 veces
1
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);
2 Respuestas
1
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
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);
respondido 28 mar '13, 14:03
No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas android android-scrollview or haz tu propia pregunta.
Are you calling setContentView(sv); ? - Andi Jay
no, I'm calling setContentView(R.layout.main) which contains the scrollview - bwoogie