@Override
public View getView(int position, View convertView, ViewGroup parent) {
View view=null;
Bean bean=list.get(position);
Log.d("bean", bean.toString());
int size = bean.getUrl_list().size();
Log.i("size", size+"/");
if(bean.isHas_image()==false){
view=View.inflate(context,R.layout.fragment1_layout_adapter,null);
TextView title= (TextView) view.findViewById(R.id.tv_title_1);
title.setText(bean.getTitle());
}
if(bean.isHas_image()==true){
view=View.inflate(context,R.layout.fragment1_layout_adapter,null);
TextView textView= (TextView) view.findViewById(R.id.tv_title_1);
ImageView imageview = (ImageView) view.findViewById(R.id.iv_image_1);
textView.setText(bean.getTitle());
imageloader.displayImage(bean.getMiddle_image(), imageview);
}
if(size>0){
view=View.inflate(context,R.layout.fragment2_layout_adapter,null);
TextView title2= (TextView) view.findViewById(R.id.tv_title_2);
ImageView image1= (ImageView) view.findViewById(R.id.iv_image1_2);
ImageView image2= (ImageView) view.findViewById(R.id.iv_image2_2);
ImageView image3= (ImageView) view.findViewById(R.id.iv_image3_2);
title2.setText(bean.getTitle());
imageloader.displayImage(bean.getUrl_list().get(0),image1);
imageloader.displayImage(bean.getUrl_list().get(1),image2);
imageloader.displayImage(bean.getUrl_list().get(2),image3);
}
return view;
}
//布局1
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<TextView
android:layout_width="match_parent"
android:layout_weight="1"
android:layout_marginRight="10dp"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:gravity="center_horizontal"
android:textSize="10dp"
android:id="@+id/tv_title_1"/>
<ImageView
android:layout_width="85dp"
android:layout_marginRight="17dp"
android:layout_height="100dp"
android:id="@+id/iv_image_1"/>
</LinearLayout>
//布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="@+id/tv_title_2"
android:textSize="10dp"
android:layout_marginRight="10dp"
android:layout_margin="10dp"/>
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content">
<ImageView
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:id="@+id/iv_image1_2"/>
<ImageView
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_marginRight="5dp"
android:layout_marginLeft="5dp"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:id="@+id/iv_image2_2"/>
<ImageView
android:layout_width="wrap_content"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:id="@+id/iv_image3_2"/>
</LinearLayout>
</LinearLayout>