我想在countersunk中设置contact_array_from_db的大小。我尝试了下面的代码,但它没有用。
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);
,但它没有用。
答案 0 :(得分:1)
试试这个:
countershv.setText(""+counterhanu);
而不是:
countershv.setText(counterhanu);
答案 1 :(得分:1)
也许你可以解释一下,或者减少你自己的问题。我看到了很多代码,这些都与问题有关吗?我看到你正在使用数据库连接,该连接是否有效?你知道网络连接不是即时的。
你不能.setText(整数i)你必须使用.setText(String str)或其他东西。所以你使用以下三种中的一种:
textView.setText(intergerValue + "");
textView.setText("" + intergerValue);
textView.setText(Interger.toString(intergerValue));
textView.setText(R.string.value); // this is a static string value in /res/values/strings.xml
因此,下次调试时尝试使用更少的代码进行相同操作。我的意思是你想要设置一个从数据库连接中恢复的整数。但是如果你测试过你自己设置的int也不会有用,你可能自己也看过这个bug,或者你可以在这里问一个简短的问题。