1. 程式人生 > >難道我學的是介面卡和快取原理例項(多圖)

難道我學的是介面卡和快取原理例項(多圖)

看了大大的進步的是神速啊,結果還是要在這裡打程式碼。感覺至少要到能畫出有自信給別人看的作品的程度,才能開始真正的進步,不然就只是一點點在原地掙扎。(來自一個上課摸魚的學生黨)

先打程式碼吧,把之前的部落格補上,不知道圖會不會被和諧??

頁面跳轉的部分畫法

 public void onClick(View v) {
        switch (v.getId()) {
            case R.id.articles_imagev:
                //單純的頁面跳轉
                Intent intent = new Intent(MainActivity.this,PaoPaoActivity.class);
                this.startActivity(intent);
                break;
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical"
    tools:context="com.example.administrator.paopao.activity.daily.PaoPaoActivity">

    <ListView
        android:id="@+id/paopao_lv"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

    </ListView>

</LinearLayout>

public class Daily {

    private int categoryId;
    private int classifyId;
    private String classifyName;

    public Daily(int categoryId, int classifyId, String classifyName) {
        this.categoryId = categoryId;
        this.classifyId = classifyId;
        this.classifyName = classifyName;
    }

    public int getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(int categoryId) {
        this.categoryId = categoryId;
    }

    public int getClassifyId() {
        return classifyId;
    }

    public void setClassifyId(int classifyId) {
        this.classifyId = classifyId;
    }

    public String getClassifyName() {
        return classifyName;
    }

    public void setClassifyName(String classifyName) {
        this.classifyName = classifyName;
    }
}


為什麼全是程式碼呢?因為過了一個星期我感覺已經記不得了
public class DailyAdapter extends BaseAdapter {

    private Context context;
    private List<Daily> dailyList;

    public DailyAdapter(Context context, List<Daily> dailyList) {
        this.context = context;
        this.dailyList = dailyList;
    }

    @Override
    public int getCount() {
        return dailyList.size();
    }

    @Override
    public Object getItem(int position) {
        return dailyList.get(position);
    }

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {


        View view = null;
        ViewHolder viewHolder = null;
        //先建立一個內部類,用來放定義控制元件,然後在if語句中判斷converview是否為空,第一次應該是空的,然後繫結id
        if (convertView == null) {
            //例項化view
            view = LayoutInflater.from(context).inflate(R.layout.richang_item, null);
            viewHolder = new ViewHolder();
            viewHolder.tv = view.findViewById(R.id.richang_item_list_tv);
            //將viewHolder打包
            view.setTag(viewHolder);
        } else {
            //第二次直接判斷時,converview不為空,直接執行這一步
            view = convertView;
            viewHolder = (ViewHolder) view.getTag();
        }
        //賦值
        viewHolder.tv.setText(dailyList.get(position).getClassifyName());
        return view;
    }
    //建立內部類,建立控制元件
    public class ViewHolder {
        TextView tv;
    }
}

哎寫不下去了,溜了