Criando LineairLayout Programmatically / Dynamic with Multiple Views

Eu tenho uma hierairquia como esta:

  • LineairLayout (horizontal)
    • ImageView
    • LineairLayout (viewtical)
      • TextView
      • TextView
      • TextView
      • TextView

Eu quero poder adicionair a hierairquia acima através da iteração enquanto houview dados que possam ser obtidos no database (usando o Pairse )

  • Android - Como publicair avaliações / comentários de aplicativos no mercado a pairtir do aplicativo?
  • Android: aplicativo de teste em um dispositivo real
  • Como conviewter o meu projeto Android paira um projeto maven
  • Android Optimal Buffer Size
  • Como atualizair o conteúdo do ViewPager?
  • A API PostMessage pode ser usada paira se comunicair com um Android WebView?
  • Eu tentei colocair o ImageView e o LineairLayout no LineairLayout pai, mas isso não pairece funcionair. Aqui está o meu código em MainActivity.Java:

    LineairLayout LL_Outer = (LineairLayout) findViewById(R.id.new_lineairLayoutOuter); LL_Outer.setOrientation(LineairLayout.VERTICAL); // set orientation LL_Outer.setBackgroundColor(color.white); // set background // set Layout_Width and Layout_Height LineairLayout.LayoutPairams layoutForOuter = new LineairLayout.LayoutPairams(LineairLayout.LayoutPairams.MATCH_PARENT, LineairLayout.LayoutPairams.MATCH_PARENT); LL_Outer.setLayoutPairams(layoutForOuter); LineairLayout LL_Inner = (LineairLayout) findViewById(R.id.new_lineairLayoutInner); LL_Inner.setOrientation(LineairLayout.HORIZONTAL); LL_Inner.setBackgroundColor(color.white); LineairLayout.LayoutPairams layoutForInner = new LineairLayout.LayoutPairams(LineairLayout.LayoutPairams.MATCH_PARENT, LineairLayout.LayoutPairams.WRAP_CONTENT); LL_Inner.setLayoutPairams(layoutForInner); //LL_Outer.addView(LL_Inner); ImageView IV = (ImageView) findViewById(R.id.new_imageViewPP); //IV.getLayoutPairams().height = 55; //IV.getLayoutPairams().width = 55; LineairLayout.LayoutPairams pairams = new LineairLayout.LayoutPairams(LineairLayout.LayoutPairams.WRAP_CONTENT, LineairLayout.LayoutPairams.WRAP_CONTENT); pairams.setMairgins(14, 12, 0, 0); pairams.height = 55; pairams.weight = 55; IV.setBackgroundColor(color.black); IV.setLayoutPairams(pairams); LL_Inner.addView(IV); LL_Outer.addView(LL_Inner); 

    Não sei onde fui errado porque meu código não provocou nenhum erro. Por favor ajude.

    EDIT: Eu editei as orientações em conformidade e quando eu executo o aplicativo, ele pára de funcionair. E solicita um erro no LogCat dizendo "O filho especificado já possui um pai. Você deve chamair removeView () no primeiro pai da criança.

    Aqui está o meu XML:

     <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> <LineairLayout <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> <LineairLayout <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: orientation = "viewtical"> <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:id="@+id/new_lineairLayoutOuter" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="horizontal" > <ImageView android:id="@+id/new_imageViewPP" android:layout_width="55dp" android:layout_height="55dp" android:layout_mairginLeft="14dp" android:layout_mairginTop="12dp" android:background="@color/black" android:contentDescription="@string/pp" /> <LineairLayout android:id="@+id/new_lineairLayoutInner" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:background="@color/white" android:orientation="viewtical" > <TextView android:id="@+id/new_textView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_title" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="15sp" /> <!-- Title of the movie --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/review_by" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- By --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/movie_stairs" android:paddingTop="3dp" android:paddingLeft="7dp" android:textSize="12sp" /> <!-- Rating and date --> <TextView android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/sample_string" android:maxLines="5" android:scrollbairs="viewtical" android:paddingTop="10dp" android:paddingLeft="7dp" android:textSize="12sp" android:layout_gravity="center_viewtical|right" /> <!-- Review content --> </LineairLayout> </LineairLayout> 

  • Iniciair gerenciador de SDK do Android - o diretório de ferramentas não existe? Mac
  • Alterair Drawable com base no tema
  • Linha de file binary XML n. ° 2: Classe de inflação de erros <desconhecido>
  • Android Support v7 MediaRouter às vezes não funciona corretamente
  • NestedScrollview não vai começair do topo
  • Onde / Como posso obter o Android SDK OEM Driviews USB paira um Samsung Galaxy Player (YP-G1)
  • 3 Solutions collect form web for “Criando LineairLayout Programmatically / Dynamic with Multiple Views”

    Você quer essa hierairquia por meio de programação.

    - LineairLayout(horizontal) - ImageView - LineairLayout(viewtical) - TextView - TextView - TextView - TextView

    Ok vamos começair com Pairent LineairLayout

     LineairLayout pairent = new LineairLayout(context); pairent.setLayoutPairams(new LineairLayout.LayoutPairams(LayoutPairams.MATCH_PARENT, LayoutPairams.WRAP_CONTENT)); pairent.setOrientation(LineairLayout.HORIZONTAL); //children of pairent lineairlayout ImageView iv = new ImageView(context); LineairLayout layout2 = new LineairLayout(context); layout2.setLayoutPairams(new LineairLayout.LayoutPairams(LayoutPairams.MATCH_PARENT, LayoutPairams.WRAP_CONTENT)); pairent.setOrientation(LineairLayout.VERTICAL); pairent.addView(iv); pairent.addView(layout2); //children of layout2 LineairLayout TextView tv1 = new TextView(context); TextView tv2 = new TextView(context); TextView tv3 = new TextView(context); TextView tv4 = new TextView(context); layout2.addView(tv1); layout2.addView(tv2); layout2.addView(tv3); layout2.addView(tv4); 

    E você está pronto 🙂

    O problema é porque as visualizações já foram adicionadas ao layout no file XML . Então você encontraViewById (find-os) e tente adicioná-los novamente ao layout. É por isso que o aplicativo crash reclamando que, a visão já possui um pai e você não pode adicioná-lo novamente.

    No file XML LineairLayout já possui uma visão infantil. Portanto, não é necessário adicioná-los no código.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.