为什么getview方法不起作用?

时间:2015-05-27 09:37:38

标签: listview getview

我有自定义列表视图来显示我的数据 我也有一个客户适配器。 我的问题是((为什么getview方法不起作用?)) 我的适配器代码是:

package ir.mrcoder.triples;

import java.util.ArrayList;
import java.util.List;   
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class myAdapter extends ArrayAdapter<job> {

List<job> JobsList=new ArrayList<job>();
private Context context;
TextView JobsName;
TextView JobsTime;
TextView JobsDate;
job TestJob;

public myAdapter(Context context, int resource,List<job> objects) 
{
    super(context, resource, objects);
    this.JobsList=objects;
    this.context=context;
}

@Override
public View getView(int position, View convertView, ViewGroup parent)
{
    LayoutInflater inflater =  (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
    convertView = inflater.inflate(R.layout.my_listview, parent, true);
    JobsName=(TextView)convertView.findViewById(R.id.JobsName);
    JobsTime=(TextView)convertView.findViewById(R.id.JobsTime);
    JobsDate=(TextView)convertView.findViewById(R.id.JobsDate);
    job myJob=JobsList.get(position);
    JobsName.setText(myJob.name);
    JobsTime.setText(myJob.timeOfDoing);
    JobsDate.setText(myJob.dateOfDoing);
    return convertView;
}
}

我以这种方式调用列表视图和适配器:

  List<job> JobsList=new ArrayList<job>();
    ListView JobShowList=(ListView)findViewById(R.id.JobShowList);
    myAdapter adapter = new myAdapter(MainActivity.this, R.layout.my_listview, JobsList);
    JobShowList.setAdapter(adapter);

我的问题是((为什么getview方法不起作用?)

0 个答案:

没有答案