标签:
item.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <FrameLayout android:id="@+id/item_no" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <TextView android:id="@+id/no_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaa" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/no_fromname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaa" /> <TextView android:id="@+id/no_showtime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaa" android:layout_marginLeft="20dp" /> </LinearLayout> </LinearLayout> </FrameLayout> <FrameLayout android:id="@+id/item_one" android:layout_width="match_parent" android:layout_height="wrap_content" > <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="horizontal" > <ImageView android:id="@+id/one_iv" android:layout_width="100dp" android:layout_height="100dp" android:src="@drawable/ic_launcher" /> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:layout_weight="1" android:orientation="vertical" > <TextView android:id="@+id/one_title" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaa" /> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal" > <TextView android:id="@+id/one_fromname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaa" /> <TextView android:id="@+id/one_showtime" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="aaa" /> </LinearLayout> </LinearLayout> </LinearLayout> </FrameLayout>
</RelativeLayout>
baseadapter.java
NewsData myData = mList.get(arg0); if (myData.getIMAGEURL() !=null) {// 如果有图片 arg1 = LayoutInflater.from(context).inflate(R.layout.item, null); arg1.findViewById(R.id.item_no).setVisibility(View.GONE); TextView one_title = (TextView) arg1.findViewById(R.id.one_title); TextView one_fromname = (TextView) arg1.findViewById(R.id.one_fromname); TextView one_showtime = (TextView) arg1.findViewById(R.id.one_showtime); ImageView one_iv = (ImageView) arg1.findViewById(R.id.one_iv); one_title.setText(mList.get(arg0).getTITLE()); one_fromname.setText(mList.get(arg0).getFROMNAME()); one_showtime.setText(mList.get(arg0).getSHOWTIME()); bitmap.display(one_iv, mList.get(arg0).getIMAGEURL()); } else {// 没有图片 arg1 = LayoutInflater.from(context).inflate(R.layout.item, null); arg1.findViewById(R.id.item_one).setVisibility(View.GONE); TextView no_title = (TextView) arg1.findViewById(R.id.no_title); TextView no_fromname = (TextView) arg1.findViewById(R.id.no_fromname); TextView no_showtime = (TextView) arg1.findViewById(R.id.no_showtime); no_title.setText(mList.get(arg0).getTITLE()); no_fromname.setText(mList.get(arg0).getFROMNAME()); no_showtime.setText(mList.get(arg0).getSHOWTIME()); } return arg1;
图文混排
原文地址:http://www.cnblogs.com/nanze/p/5403675.html