50、微信-朋友圈AlbumActivity

public class AlbumActivity extends BaseActivity implements View.OnClickListener {
private TextView txt_title;
private ImageView img_talk;
private ListView mlistview;
private View layout_head;

@Override
public void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.activity_listview);
super.onCreate(savedInstanceState);
}

@Override
protected void onResume() {
super.onResume();
}

@Override
protected void onDestroy() {
super.onDestroy();
}

@Override
protected void initControl() {
findViewById(R.id.img_back).setVisibility(View.VISIBLE);
txt_title = (TextView) findViewById(R.id.txt_title);
txt_title.setText("朋友圈");
img_talk = (ImageView) findViewById(R.id.img_right);
img_talk.setVisibility(View.VISIBLE);
img_talk.setImageResource(R.drawable.icon_talk);
mlistview = (ListView) findViewById(R.id.listview);

layout_head = getLayoutInflater().inflate(R.layout.layout_album_header, null);
mlistview.addHeaderView(layout_head);
mlistview.setAdapter(new AlbumAdpter(this));
}

@Override
protected void initView() {
// TODO Auto-generated method stub

}

@Override
protected void setListener() {
findViewById(R.id.img_back).setOnClickListener(this);
img_talk.setOnClickListener(this);
img_talk.setOnLongClickListener(new View.OnLongClickListener() {

@Override
public boolean onLongClick(View v) {
Utils.showLongToast(context, "长按发送文字");
return true;
}
});
}

@Override
protected void initData() {
// TODO Auto-generated method stub

}

@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.img_back:
Utils.finish(AlbumActivity.this);
break;
case R.id.img_right:
Utils.start_Activity(this, ShareActivity.class);
break;
default:
break;
}
}

}
仍然使用了通用的列表布局: activity_listview
增加了一个列表头: layout_album_header


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="15dp"
android:background="@color/white"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:gravity="center_horizontal"
android:layout_width="fill_parent"
android:layout_height="280dp">

<TextView
android:textSize="20sp"
android:id="@+id/txt_name"
android:text="菲儿"
android:gravity="right|bottom"
android:paddingRight="110dp"
android:paddingBottom="10dp"
android:background="@drawable/user_ba"
android:layout_width="fill_parent"
android:textColor="@color/white"
android:layout_height="240dp" />
<ImageView
android:id="@+id/head"
android:contentDescription="@string/app_name"
android:layout_width="80.0dip"
android:layout_height="80.0dip"
android:layout_marginRight="15dp"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@drawable/head" />
</RelativeLayout>

</LinearLayout>
适配器是 AlbumAdpter:
public class AlbumAdpter extends BaseAdapter {
protected Context context;
LayoutInflater mInflater;

public AlbumAdpter(Context ctx) {
context = ctx;
}

@Override
public int getCount() {
return 15;
}

@Override
public Object getItem(int position) {
return null;
}

@Override
public long getItemId(int position) {
return position;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = LayoutInflater.from(context).inflate(R.layout.layout_item_album, parent, false);
}

return convertView;
}
}

子项布局:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<LinearLayout
android:id="@+id/contactitem_layout"
style="@style/MMListItem"
android:gravity="top"
android:layout_height="wrap_content"
android:background="@color/white"
android:padding="10dip" >


<ImageView
android:id="@+id/img_head"
android:layout_width="50.0dip"
android:layout_height="50.0dip"
android:scaleType="centerCrop"
android:src="@drawable/head" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
android:orientation="vertical"
android:paddingLeft="10dip"
android:paddingBottom="5dp">
<TextView
android:id="@+id/txt_content"
style="@style/MMFontTitleInList"
android:textColor="@color/blue1"
android:textSize="18sp"
android:text="老婆" />
<TextView
android:id="@+id/txt_msg"
android:layout_below="@+id/txt_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="我是多幸福啊!辛苦了亲爱的!么么哒!~"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:textSize="16sp"
android:singleLine="true" />

<LinearLayout
android:id="@+id/layout_photo"
android:layout_below="@+id/txt_msg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:gravity="center_vertical">
<ImageView
android:id="@+id/img_photo1"
android:layout_width="80.0dip"
android:layout_height="80.0dip"
android:scaleType="centerCrop"
android:src="@drawable/gr" />
<ImageView
android:id="@+id/img_photo2"
android:layout_margin="5dp"
android:paddingLeft="10dp"
android:layout_width="80.0dip"
android:layout_height="80.0dip"
android:scaleType="centerCrop"
android:src="@drawable/gr" />
<ImageView
android:id="@+id/img_photo3"
android:layout_margin="5dp"
android:paddingLeft="10dp"
android:layout_width="80.0dip"
android:layout_height="80.0dip"
android:scaleType="centerCrop"
android:src="@drawable/gr" />
</LinearLayout>

<TextView
android:id="@+id/txt_time"
android:layout_below="@+id/layout_photo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="56分钟前"
android:textColor="@color/black1"
android:textSize="12sp"
android:singleLine="true" />

<ImageView
android:id="@+id/img_zan"
android:layout_alignParentRight="true"
android:layout_below="@+id/layout_photo"
android:layout_width="23dp"
android:layout_height="16dp"
android:scaleType="fitXY"
android:src="@drawable/afr" />

</RelativeLayout>
</LinearLayout>
<View
android:background="@color/black2"
android:layout_width="fill_parent"
android:layout_height="1.0dip" />
</LinearLayout>





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

asmcvc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值