XListView的布局
来源:互联网 发布:学java可以开发游戏吗 编辑:程序博客网 时间:2024/05/29 09:14
import java.util.ArrayList;
import android.annotation.SuppressLint;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
public class BlogsAdapter extends BaseAdapter {
private ArrayList<Blogs> list;
private Context context;
public BlogsAdapter(ArrayList<Blogs> list, Context context) {
super();
this.list = list;
this.context = context;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return list.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@SuppressLint("ViewHolder")
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View inflate = View.inflate(context, R.layout.item, null);
TextView title = (TextView) inflate.findViewById(R.id.title);
TextView body = (TextView) inflate.findViewById(R.id.body);
TextView author = (TextView) inflate.findViewById(R.id.author);
TextView pubDate = (TextView) inflate.findViewById(R.id.pubDate);
TextView commentCount = (TextView) inflate.findViewById(R.id.commentCount);
title.setText(list.get(position).getTitle());
body.setText(list.get(position).getBody());
author.setText(list.get(position).getAuthorname());
pubDate.setText(list.get(position).getPubDate());
commentCount.setText(list.get(position).getCommentCount());
return inflate;
}
}
bean包
package com.example.yuekao1;
public class Blogs {
private String title;
private String body;
private String pubDate;
private String authorname;
private String commentCount;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public String getPubDate() {
return pubDate;
}
public void setPubDate(String pubDate) {
this.pubDate = pubDate;
}
public String getAuthorname() {
return authorname;
}
public void setAuthorname(String authorname) {
this.authorname = authorname;
}
public String getCommentCount() {
return commentCount;
}
public void setCommentCount(String commentCount) {
this.commentCount = commentCount;
}
}
fragment布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.yuekaolianxi1.MainActivity" >
<com.example.yuekao1.XListView
android:id="@+id/lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</RelativeLayout>
XListView的item布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.yuekaolianxi1.MainActivity" >
<TextView
android:id="@+id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:textColor="#000"
android:text="title"
/>
<TextView
android:id="@+id/body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/title"
android:text="内容"
/>
<TextView
android:id="@+id/author"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/body"
android:text="sss"
/>
<TextView
android:id="@+id/pubDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/body"
android:text="2016"
android:layout_toRightOf="@+id/author"
android:layout_marginLeft="20dp"
/>
<TextView
android:id="@+id/commentCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="@+id/pubDate"
android:text="23"
android:layout_marginLeft="20dp"
android:layout_below="@+id/body"
/>
</RelativeLayout>
- XListView的布局
- XListView的多布局优化
- XlistView的使用加XlistView的多布局
- xlistview布局
- xlistview布局
- xlistview布局
- XListView的多布局和解析
- xListView头尾布局
- VIewPager+XListView+RadioButton实现布局
- Xlistview实现多条目布局
- XlistView 最后把你的第三方的布局和代码导入你的项目里、
- pulltorefreshlistview 和xlistview 中的获取item控件布局时出现的类转换异常的问题:
- 抽屉布局+xlistview+上拉、下拉+imageLoad
- XListView加头布局ViewPager轮播
- XListview第三方listview布局框架
- xlistview的使用
- xListView的使用步骤
- Xlistview的滚动控制
- Spring事务的隔离级别
- 高版本ubuntu安装低版本arm-linux-gcc
- JSTL
- 【C++ 学习】01 资源整理
- bootStrap实习原理
- XListView的布局
- POJ 2151 Check the difficulty of problems 概率DP
- HDU-1095
- 编程之美1.15构造数独---置换法java版
- change background color in chrome
- 数组元素过半问题
- java之用户登录界面
- 九度OJ 1078
- shell中$(( ))与$( )还有${ }的区别