2012-07-13 5 views
0

내가하려는 것은 로컬 비즈니스를 찾는 응용 프로그램을 만드는 것입니다. 그래서 내가하는 활동은 비즈니스 정보를 표시합니다. 일부 비즈니스는 도시에있는 severals 상점을 가지고 있으며, 일부 상점에는 도시가있는 상점 만 있습니다. 그래서 여기 내 문제가 있습니다 :보기에서 모든 요소와 스크롤보기 및 scrollview 안에 선형 레이아웃이 있습니다. 비즈니스에 상점이 두 개 이상있는 경우 각 상점 정보를 새 텍스트보기에 추가하고 텍스트보기를 레이아웃에 추가합니다 (모든 코드로 완료). 그러나 레이아웃을 표시하는 순간에는 3 또는 4를 표시하는 대신 하나의 상점 만 표시합니다. 내가 뭘 잘못하고있는 걸까요? 내보기의 XML 여기LinearLayout에 항목이 표시되지 않습니다.

private void setupViews() throws SQLException { 
     ImageView iv = (ImageView) findViewById(R.id.negocio_logo); 
     try { 
      iv.setImageBitmap(BitmapFactory.decodeByteArray(toShow.getImgSrc(), 
        0, toShow.getImgSrc().length)); 
     } catch (NullPointerException npe) { 
      iv.setBackgroundColor(Color.WHITE); 
     } 
     TextView nombreEmpresa = (TextView) findViewById(R.id.nombre_empresa); 
     nombreEmpresa.setText(toShow.getNombre()); 
     TextView descripcionEmpresa = (TextView) findViewById(R.id.descripcion_empresa); 
     descripcionEmpresa.setText(toShow.getDescripcion()); 
     TextView direccionEmpresa = (TextView) findViewById(R.id.direccion_empresa); 
     direccionEmpresa.setText(toShow.getDireccion()); 

     LinearLayout rl = (LinearLayout) findViewById(R.id.linear_layout_si); 
     TextView suc = (TextView) findViewById(R.id.sucursales_empresa); 
     sucursalDAO sDAO = new sucursalDAO(); 
     boolean tieneSucursales = sDAO.hasSucursales(toShow.getId()); 
     if (tieneSucursales == false) { 
      suc.setVisibility(View.GONE); 
      // sucs.setVisibility(View.GONE); 

     } else { 
      suc.setVisibility(View.VISIBLE); 

      ArrayList<String> sucursales = sDAO.getStringSucursales(toShow 
        .getId()); 
      ArrayList<TextView> tvs = new ArrayList<TextView>(); 
      for (int i = 0; i < sucursales.size(); i++) { 
       TextView tv = new TextView(this); 
       tv.setText(sucursales.get(i)); 
       tv.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, 
         LayoutParams.WRAP_CONTENT)); 
       tvs.add(tv); 
      } 
      for (int i = 0; i < tvs.size(); i++) { 
       rl.addView(tvs.get(i), i); 


      } 

     } 

    } 

을 그리고있다 :

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RL" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:background="@color/White" 
    android:orientation="vertical" > 

    <ScrollView 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/widgetscroll" 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <RelativeLayout 
      xmlns:android="http://schemas.android.com/apk/res/android" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/White" 
      android:orientation="vertical" > 

      <ImageView 
       android:id="@+id/negocio_logo" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_centerHorizontal="true" 
       android:contentDescription="@string/logo_negocio" /> 

      <TextView 
       android:id="@+id/datos_empresa" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/negocio_logo" 
       android:background="@drawable/barra" 
       android:text="@string/datos_empresa" 
       android:textColor="@color/White" /> 

      <TextView 
       android:id="@+id/nombre_empresa" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/datos_empresa" 
       android:text="@string/testing" /> 

      <TextView 
       android:id="@+id/descripcion_empresa" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/nombre_empresa" 
       android:text="@string/testing" /> 

      <TextView 
       android:id="@+id/direccion_empresa" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/descripcion_empresa" 
       android:text="@string/testing" /> 

      <TextView 
       android:id="@+id/sucursales_empresa" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/direccion_empresa" 
       android:background="@drawable/barra" 
       android:text="@string/sucursales" 
       android:visibility="gone" /> 

      <LinearLayout 
       android:id="@+id/linear_layout_si" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/sucursales_empresa" > 
      </LinearLayout> 

      <TextView 
       android:id="@+id/contacto_empresa" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:layout_below="@id/linear_layout_si" 
       android:text="@string/testing" /> 

     </RelativeLayout> 
    </ScrollView> 

</RelativeLayout> 

답변

3

LinearLayout에서 방향을 설정하는 것을 잊어 버렸고 horitzontal을 표시하고 있습니다.

+0

예, 그게 전부입니다! 감사! – CarlosT

+0

de nada;) 그 변수 이름은 나에게 익숙한 것 같습니다. – Litus

1

난 당신의 orientation을 설정하는 것을 잊었다 내기가 여기에 표시 chanrge의 하나 인 방법 setupViews()이다 LinearLayout.

+1

예, 감사했습니다. – CarlosT

관련 문제