我使用https://github.com/thest1/LazyList作为我的列表视图
我想知道如何检查列表视图是空还是空?
这是来自执行后的示例代码
@Override
protected void onPostExecute(Void args) {
// Locate the listview in listview_main.xml
// Pass the results into ListViewAdapter.java
adapter = new LvOrderSumAdapter(OrderSum.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
listview.getAdapter().getCount();
String count = ""+listview.getAdapter().getCount();
items.setText(count);
// Close the progressdialog
mProgressDialog.dismiss();
}
请帮忙! 我从我搜索的内容中尝试了这段代码
if(!arraylist.isEmpty()){
listview = (ListView) findViewById(R.id.listOrderSummary);
// Pass the results into ListViewAdapter.java
adapter = new LvOrderSumAdapter(OrderSum.this, arraylist);
// Set the adapter to the ListView
listview.setAdapter(adapter);
listview.getAdapter().getCount();
String count = ""+listview.getAdapter().getCount();
items.setText(count);
//o_total.setText("aaa");
// Close the progressdialog
mProgressDialog.dismiss();
}else{ String msg = "No records found in Database!";
Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_LONG).show();
Intent home_in = new Intent ( OrderSum.this,
Home.class );
startActivity(home_in);
overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_left);
}
但我仍然有错误
Error parsing data org.json.JSONException: Value <br of type java.lang.String cannot be converted to JSONObject"
答案 0 :(得分:0)
检查listView是否为null:
listView != null;
检查listView是否没有元素:
listView.getAdapter().getCount()<=0;