一、明日计划
在云服务器上建立数据库,进行PDF文档的存储,实现PDF的上传功能,解决书籍来源的问题
二、今日成果
利用BaseAdapter的功能完成了索引卡四的书籍列表功能
原码
package com.example.fooks.entity; public class Book { private int id; private String BookName; private String BookPath; private String CreateUser; private String CreateDate; public int getId() { return id; } public void setId(int id) { this.id = id; } public String getBookName() { return BookName; } public void setBookName(String bookName) { BookName = bookName; } public String getBookPath() { return BookPath; } public void setBookPath(String bookPath) { BookPath = bookPath; } public String getCreateUser() { return CreateUser; } public void setCreateUser(String createUser) { CreateUser = createUser; } public String getCreateDate() { return CreateDate; } public void setCreateDate(String createDate) { CreateDate = createDate; } @Override public String toString() { return "Book{" + "id=" + id + ", BookName=‘" + BookName + ‘\‘‘ + ", BookPath=‘" + BookPath + ‘\‘‘ + ", CreateUser=‘" + CreateUser + ‘\‘‘ + ", CreateDate=‘" + CreateDate + ‘\‘‘ + ‘}‘; } public Book() { } public Book(String bookName, String bookPath, String createUser, String createDate) { BookName = bookName; BookPath = bookPath; CreateUser = createUser; CreateDate = createDate; } public Book(int id, String bookName, String bookPath, String createUser, String createDate) { this.id = id; BookName = bookName; BookPath = bookPath; CreateUser = createUser; CreateDate = createDate; } }
package com.example.fooks.utils; import android.content.Context; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.TextView; import com.example.fooks.R; import com.example.fooks.ReadActivity; import com.example.fooks.entity.Book; import java.util.List; public class BooksAdapter extends BaseAdapter { private List<Book> mList; private Context mContext; private LayoutInflater mLayoutInflater; public BooksAdapter(List<Book> mList, Context mContext) { this.mList = mList; this.mContext = mContext; this.mLayoutInflater = LayoutInflater.from(mContext); } @Override public int getCount() { return mList.size(); } @Override public Object getItem(int position) { return mList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder viewHolder; if(convertView==null) { viewHolder= new ViewHolder(); convertView=mLayoutInflater.inflate(R.layout.booklist,null); viewHolder.mBook= convertView.findViewById(R.id.book_show); convertView.setTag(viewHolder); }else { viewHolder=(ViewHolder)convertView.getTag(); } Book book=mList.get(position); viewHolder.mBook.setText(book.getBookName()); return convertView; } }
package com.example.fooks.utils; import android.widget.TextView; public class ViewHolder { public TextView mBook; }
原文:https://www.cnblogs.com/yeyueweiliang/p/12722762.html