50、微信-朋友圈AlbumActivity
来源:互联网 发布:js开发日历时间控件 编辑:程序博客网 时间:2024/04/30 01:59
public class AlbumActivity extends BaseActivity implements View.OnClickListener {仍然使用了通用的列表布局:activity_listview
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;
}
}
}
增加了一个列表头:layout_album_header
<?xml version="1.0" encoding="utf-8"?>适配器是AlbumAdpter:
<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>
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>
0 0
- 50、微信-朋友圈AlbumActivity
- 微信朋友圈是什么?
- 微信朋友圈厚黑学
- 微信朋友圈分享
- 微信分享好友,朋友圈
- 微信及朋友圈分享
- 微信分享好友,朋友圈
- 微信朋友圈api使用
- android微信朋友圈分享
- 微信朋友圈广告,杀鸡取卵?
- 微信朋友圈还能活多久
- 微信朋友圈布局实现
- iOS 分享微信朋友圈
- iOS 微信分享 朋友圈
- Umeng微信、朋友圈分享
- Umeng微信、朋友圈分享
- 微信朋友圈广告规范
- 微信朋友圈运营规则
- C++虚继承(一) --- vtordisp字段
- 欢迎使用CSDN-markdown编辑器
- (转)Android 三星手机拍照,从图库选择照片旋转问题完美解决
- 横竖屏切换时,简单解决webview重新载入问题
- IOS 线程
- 50、微信-朋友圈AlbumActivity
- IOS性能调优系列:使用Instruments动态分析内存泄漏,调优instruments
- 自定义注解
- iOS把所有界面的状态栏的字体颜色都设置为白色
- ANT教程经典
- github学习笔记
- 使用Retrofit和RxJava的生命周期管理
- 沉舟侧畔千帆过,病树前头万木春
- Instruments- time profiler