Posts

Showing posts with the label listview

What is the best trick to handle null values in Recycler-view onBindViewHolder?

What is the best trick to handle null values in Recycler-view onBindViewHolder? I handled many exception regarding null/index-outof-bound etc. But i am thinking that this is not right way to go like if/else , so anyone can guide me How to handle all null condition in onBindViewHolder? @Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { if (holder instanceof CustDtlsHolder) { // >i am getting here lots of null values below if(position < arr_custdetails.size()) { String dateInString = arr_custdetails.get(position).getLastVisitDate(); Date date = null; SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); try { date = formatter.parse(dateInString); SimpleDateFormat formatter2 = new SimpleDateFormat("dd/MMM/yyyy...

TListView detecting ESC or unchanged editing

TListView detecting ESC or unchanged editing I am trying to subclass the WindowProc of TListView to detect ESC key press after editing TListView caption (if user cancels editing). ListViewWndProc is getting called clearly, but the code parameter which is supposed to detect that never gets LVN_ENDLABELEDIT value. Why the commented part never gets called? I cannot see the error, it should be happening. WindowProc TListView TListView TWndMethod OldWndProc; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { OldWndProc = ListView1->WindowProc; ListView1->WindowProc = ListViewWndProc; } //--------------------------------------------------------------------------- void __fastcall TForm1::ListViewWndProc(TMessage &Message) { if (Message.Msg == CN_NOTIFY) { LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(Message.LParam); if (pnmh->code == LVN_ENDLABELEDIT) // UPDATE: if LVN_ENDLAB...