You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have successfully implemented Section header with Listview. Now i want to add a static listview to this list using listview.setHeaderVIew( headerview). [ Outstanding [green] and Advance [red] Part in screen shot]
Code Snippet - ` Listview fragment -
@OverRide
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
if (rootview != null) {
ViewGroup parent = (ViewGroup) rootview.getParent();
if (parent != null)
parent.removeView(rootview);
}
try {
rootview = inflater.inflate(R.layout.fragment_customer_list, container, false);
} catch (InflateException e) {
/* map is already there, just return view as it is */
}
mCustomerListHeaderAdapter = new CustomerListHeaderAdapter(getActivity(), null);
mUserListView = (ListView) rootview.findViewById(R.id.lv_user);
View emptyview = rootview.findViewById(R.id.fcl_tv_empty_list);
View headerView = inflater.inflate(R.layout.customer_list_header, mUserListView, false);
mUserListView.addHeaderView(headerView , null, false);
mUserListView.setEmptyView(emptyview);
mUserListView.setAdapter(mCustomerListHeaderAdapter);
mUserListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
int cursorPosition ;
CustomerListHeaderAdapter adapter = (CustomerListHeaderAdapter) ((HeaderViewListAdapter) adapterView.getAdapter()).getWrappedAdapter();
/* This is what I do without Listview header
CustomerListHeaderAdapter adapter = (CustomerListHeaderAdapter) adapterView.getAdapter();
But adding this, I am not able to click the item above section header [ List item - 40/a Dher ke Bal]
and if i click section header, app is crashing. [ Section Header - A ]
java.lang.ClassCastException: java.lang.String cannot be cast to android.database.Cursor at com.merapaper.merapaper.CustomerListFragment$1.onItemClick(CustomerListFragment.java:159)
( In my view, This is happening because SectionCursorAdapter.NO_CURSOR_POSITION is giving in correct result after adding static header view).
Could you please tell how to fix it.
The text was updated successfully, but these errors were encountered:
Hi,
I have successfully implemented Section header with Listview. Now i want to add a static listview to this list using listview.setHeaderVIew( headerview). [ Outstanding [green] and Advance [red] Part in screen shot]
Code Snippet - ` Listview fragment -
@OverRide
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
*/
cursorPosition = adapter.getCursorPositionWithoutSections(position);
}
CustomerListHeaderAdapter -
Context mContext ;
public CustomerListHeaderAdapter(Context context, Cursor cursor) {
// Context context = customerListItemViewHolder.rootView.getContext();
*/
String fullname = cursor.getString(CustomerListFragment.COL_FULL_NAME);
customerListItemViewHolder.nameView.setText(fullname);
/*
Double payment_amount = cursor.getDouble(CustomerListFragment.COL_PAYMENT_AMOUNT);
customerListItemViewHolder.paymentAmtView.setText(Utility.format_amount_in_cur(mContext, payment_amount));
*/
`
But adding this, I am not able to click the item above section header [ List item - 40/a Dher ke Bal]
and if i click section header, app is crashing. [ Section Header - A ]
java.lang.ClassCastException: java.lang.String cannot be cast to android.database.Cursor at com.merapaper.merapaper.CustomerListFragment$1.onItemClick(CustomerListFragment.java:159)
( In my view, This is happening because SectionCursorAdapter.NO_CURSOR_POSITION is giving in correct result after adding static header view).
Could you please tell how to fix it.
The text was updated successfully, but these errors were encountered: