什么是制作自定义适配器的标准方法

时间:2017-08-31 10:16:32

标签: android

complete code

  

它是带有模型类的自定义适配器类的完整代码......但是请帮我标准或不是.....?

"

public class CustAdapDeasiese extends BaseAdapter
{

    private Context context;
    private ArrayList<GetSetDisease> dataList;
    LayoutInflater inflater;

    public CustAdapDeasiese(Context context, ArrayList<GetSetDisease> dataList)
    {
        this.context = context;
        this.dataList = dataList;
        if(context!=null) {
            inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        }
    }
    @Override
    public int getCount() {
        return dataList.size();
    }

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

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

    @Override
    public View getView(final int position, View view, ViewGroup viewGroup) {
        /********** Inflate spinner_rows.xml file for each row ( Defined below ) ************/
        View row = inflater.inflate(R.layout.res_spinner, viewGroup, false);
        final GetSetDisease data = dataList.get(position);
        /***** Get each Model object from Arraylist ********/
        TextView txt_title             = (TextView)row.findViewById(R.id.tv_res_spn_title);
        if(data!=null) {
            txt_title.setText(data.getDiseasName().toString());
        }
        return row;
    }
}
"

1 个答案:

答案 0 :(得分:0)

它已被称为&#34;自定义适配器&#34;意味着您可以执行任何操作,以您希望的方式更改适配器以满足您的应用需求。所以没有&#39;标准&#39;这样做的方法