リストビューの項目をクリックしても何も起こりませんここにコードがあります
@SuppressLint("ParserError")
public class DinerList extends Activity implements Comparator<CanteenTagEntry>,
OnItemSelectedListener {
List<CanteenTagEntry> dinerlist;
int size;
int[] arr;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.diner_list);
ListView listView1 = (ListView) findViewById(R.id.list);
Context con = getApplicationContext();
DatabaseHelper dbHelper = new DatabaseHelper(con);
ICanteenLogRepository repository = dbHelper.getCanteenLogRepository();
try {
dinerlist = repository.total();
Collections.sort(dinerlist, new DinerList());
Collections.sort(dinerlist, new sortbyuser());
Collections.sort(dinerlist, new sortbycompany());
size = dinerlist.size();
arr = new int[size];
for (int i = 0; i < size; i++) {
CanteenTagEntry tagentry = dinerlist.get(i);
int b = tagentry.getId();
System.out.print(b);
arr[i] = tagentry.getId();
System.out.print(arr[i]);
}
} catch (SQLException e) {
Log.d("DinerList", "Unable to retrieve diner list", e);
}
CanteenAdapter adapter = new CanteenAdapter(this,
R.layout.listview_item_row,
(ArrayList<CanteenTagEntry>) dinerlist);
listView1.setAdapter(adapter);
}
public class CanteenAdapter extends ArrayAdapter<CanteenTagEntry> {
Context context;
int layoutResourceId;
ArrayList<CanteenTagEntry> data = (ArrayList<CanteenTagEntry>) dinerlist;
public CanteenAdapter(Context context, int layoutResourceId,
ArrayList<CanteenTagEntry> data) {
super(context, layoutResourceId, dinerlist);
this.layoutResourceId = layoutResourceId;
this.context = context;
this.data = (ArrayList<CanteenTagEntry>) dinerlist;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View row = convertView;
RouteHolder holder = null;
if (row == null) {
LayoutInflater inflater = ((Activity) context)
.getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new RouteHolder();
holder.txtName1 = (TextView) row.findViewById(R.id.Title1);
holder.txtName2 = (TextView) row.findViewById(R.id.Title2);
holder.txtName3 = (TextView) row.findViewById(R.id.Title3);
row.setTag(holder);
} else {
holder = (RouteHolder) row.getTag();
}
CanteenTagEntry tagentry = data.get(position);
String idcolor = tagentry.getUser().getIdcolor().toString();
try {
holder.txtName1.setTextColor(Color.parseColor(idcolor));
holder.txtName2.setTextColor(Color.parseColor(idcolor));
holder.txtName3.setTextColor(Color.parseColor(idcolor));
} catch (Exception e) {
holder.txtName1.setTextColor(Color.GRAY);
holder.txtName2.setTextColor(Color.GRAY);
holder.txtName3.setTextColor(Color.GRAY);
}
holder.txtName1.setText(tagentry.getUser().getUserType().getName());
holder.txtName2.setText(tagentry.getUser().getCompany().getName());
holder.txtName3.setText(tagentry.getUser().getFirstName());
return row;
}
class RouteHolder {
TextView txtName1;
TextView txtName2;
TextView txtName3;
TextView txtName4;
}
}
@Override
public int compare(CanteenTagEntry o1, CanteenTagEntry o2) {
return o1.getUser().getFirstName()
.compareTo(o2.getUser().getFirstName());
}
public class sortbyuser implements Comparator<CanteenTagEntry> {
@Override
public int compare(CanteenTagEntry lhs, CanteenTagEntry rhs) {
return lhs.getUser().getUserType().getName()
.compareTo(rhs.getUser().getUserType().getName());
}
}
public class sortbycompany implements Comparator<CanteenTagEntry> {
@Override
public int compare(CanteenTagEntry lhs, CanteenTagEntry rhs) {
return lhs.getUser().getCompany().getName()
.compareTo(rhs.getUser().getCompany().getName());
}
}
@Override
public void onItemSelected(AdapterView<?> l, View v, int position,
long ide) {
super.onListItemClick(l, v, position, ide);
CanteenTagEntry tagentry = null;
int pos = position;
int id = arr[pos];
int userid = 0;
Context con = getApplicationContext();
DatabaseHelper dbHelper = new DatabaseHelper(con);
ICanteenLogRepository repository = dbHelper.getCanteenLogRepository();
try {
tagentry = repository.Retrieve(id);
userid = tagentry.getUser().getId();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
StartFood food = new StartFood(id, userid);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// TODO Auto-generated method stub
}
}