-2
進行搜索我想使用發票號碼進行搜索,但它在發票中沒有提供如何解決它的錯誤。這裏是我的過濾方法&錯誤:我想使用發票號碼
顯示java.lang.NullPointerException:嘗試在空調用虛擬方法java.lang.String中java.lang.String.toLowerCase(java.util.Locale中的)'對象引用
public void filter(String charText) {
charText = charText.toLowerCase(Locale.getDefault());
billmod.clear();
if (charText.length() == 0) {
billmod.addAll(arraylist);
} else {
for (BillModel st : arraylist) {
if (st.getBill_tableno().toLowerCase(Locale.getDefault()).contains(charText)) {
billmod.add(st);
}
else if(st.getBill_date().toLowerCase(Locale.getDefault()).contains(charText)) {
billmod.add(st);
} else if(st.getBill_amount().toLowerCase(Locale.getDefault()).contains(charText)) {
billmod.add(st);
}
else if(st.getIncvoice_no().toLowerCase(Locale.getDefault()).contains(charText)) {
billmod.add(st);
}
}
}
notifyDataSetChanged();
}
你是如何設置值或數組列表? (st.getBill_tableno()返回null,請檢查值是否正確保存到arraylist中 – Sonam