layout - Place buttons into multiple columns android -


as in picture: http://es.tinypic.com/r/mug8b8/8

in month of having single column, have several botons genre buttons dynamically query function generates buttons:

private void createempresas() {     button b;     jsonobject json = null;     int count = 0;     linearlayout lm = (linearlayout) findviewbyid(r.id.linearmain);     jsonobject jobj = obj_sqlite.get_descripcion_empresas();      try {         count = integer.parseint(jobj.getstring("cont"));         json = new jsonobject(jobj.getstring("json"));     } catch (exception e) {         log.e("getparams", e.getmessage());     }      (int x = 1; x <= count; x++) {          try {             jsonobject json_row = new jsonobject(json.getstring("row" + x));              b = new button(this);             b.settext(json_row.getstring("descripcion"));             b.setid(json_row.getint("empresa"));             b.settextsize(10);             b.setpadding(8, 3, 8, 3);             b.settypeface(typeface.serif, typeface.bold_italic);             b.setlayoutparams(new layoutparams(layoutparams.wrap_content,                     layoutparams.wrap_content));              lm.addview(b);              b.setonclicklistener(new view.onclicklistener() {                 public void onclick(view v) {                     // todo auto-generated method stub                     toast.maketext(getapplicationcontext(),                             "yipee.." +v.getid(), toast.length_short)                             .show();                 }             });         } catch (exception e) {             log.e("getparams", e.getmessage());         }     } } 

my xml is:

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:background="@color/bg_main" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.example.php_mysql_sqlite.mainactivity" >  <button     android:id="@+id/button4"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbaseline="@+id/button6"     android:layout_alignbottom="@+id/button6"     android:layout_alignparentright="true"     android:layout_marginright="17dp"     android:background="@null"     android:onclick="loginout"     android:text="@string/btlogout"     android:textcolor="@color/red" />  <button     android:id="@+id/button6"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignbaseline="@+id/button5"     android:layout_alignbottom="@+id/button5"     android:layout_centerhorizontal="true"     android:onclick="syncsqlitemysql"     android:text="@string/syn" />  <button     android:id="@+id/button5"     style="?android:attr/buttonstylesmall"     android:layout_width="wrap_content"     android:layout_height="wrap_content"     android:layout_alignparentbottom="true"     android:layout_alignparentleft="true"     android:onclick="borrartabla"     android:text="@string/deltable" />  <scrollview     android:layout_width="285dp"     android:layout_height="330dp"     android:layout_margintop="1dp" >      <linearlayout         android:id="@+id/linearmain"         android:layout_width="fill_parent"         android:layout_height="fill_parent"         android:layout_alignleft="@+id/button5"         android:layout_alignparenttop="true"         android:layout_alignright="@+id/button4"         android:background="@color/white"         android:orientation="vertical" >     </linearlayout> </scrollview> 

thanks help

ps: if give me negative points, leave comment of reason, has happened before , not why

here answers may help

1- in android how add buttons tablelayout array of buttons programmatically?

2- how programmatically add buttons layout 1 one in several lines?

3- add array of buttons gridview in android application


Comments

Popular posts from this blog

c++ - No viable overloaded operator for references a map -

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - Cannot secure connection using TLS -