我想在沉頭中設置contact_array_from_db的大小。我嘗試了下面的代碼,但它不工作。在TextBox字段中設置值
TextView countershv = (TextView)findViewById(R.id.shv);
ArrayList<Hearing> contact_array_from_db = db.Get_HearingCaseall(curDate);
for (int i = 0; i < contact_array_from_db.size(); i++) {
int tidno = contact_array_from_db.get(i).getID();
String clientid = contact_array_from_db.get(i).getClientId();
String courtid = contact_array_from_db.get(i).getCourtTypeId();
String dateofhearing = contact_array_from_db.get(i).getDateofHearing();
String remarks = contact_array_from_db.get(i).getHearingRemarks();
String dateofnexthearing = contact_array_from_db.get(i).getDateofnexthearing();
String nexthearingremarks = contact_array_from_db.get(i).getNexthearingremarks();
String againstremarks = contact_array_from_db.get(i).getAgainstremarks();
String casereferences = contact_array_from_db.get(i).getCasereferences();
Hearing cnt = new Hearing();
cnt.setID(tidno);
cnt.setclient_id(clientid);
cnt.setCourtTypeId(courtid);
cnt.setDateofHearing(dateofhearing);
cnt.setHearingRemarks(remarks);
cnt.setDateofnexthearing(dateofnexthearing);
cnt.setNexthearingremarks(nexthearingremarks);
cnt.setAgainstremarks(againstremarks);
cnt.setCasereferences(casereferences);
contact_data.add(cnt);
}
int counterhanu = contact_array_from_db.size();
/*contact_data.contains(counter);*/
db.close();
cAdapter = new Contact_Adapter(Main_Screen_Hearingfull.this, R.layout.listview_hearingfull,
contact_data,counterhanu);
Contact_listview.setAdapter(cAdapter);
cAdapter.notifyDataSetChanged();
countershv .setText(counterhanu);
}
我們得到了counterhanu的值,但是我想在countershv中設置這個值。我不知道如何?我試過這個countershv.setText(counterhanu);
,但它不工作。
如何解決? – user1960700
如何解決什麼 – Blackbelt
在提問時,您需要提供更多而不是無效的東西。您需要提供堆棧跟蹤,確切的錯誤消息。這就是說,我認爲@Aashir是正確的。您發送給setText的int將導致它通過該ID搜索資源,而不是設置文本。 – Knossos