Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Expandablelistview-上下滚动数据会分散_Android - Fatal编程技术网

Android Expandablelistview-上下滚动数据会分散

Android Expandablelistview-上下滚动数据会分散,android,Android,在我的BaseExpandableListAdapter中,我有类AdapterData的列表。 此AdapterData包含付款类别的日期和对象。 我在适配器中获得每个日期的付款对象。i、 e.3月25日-付款1 3月25日-付款2、3月26日付款3、3月26日付款4、3月26日付款5等。 在我的get group视图方法中,我添加了一些逻辑,比如如果付款数据来自同一日期,那么它应该只属于该日期。 一切都很完美,只有当我向上滚动我的数据时,我的数据才会分散,也就是说,3月26日的记录将在3月2

在我的BaseExpandableListAdapter中,我有类AdapterData的列表。 此AdapterData包含付款类别的日期和对象。 我在适配器中获得每个日期的付款对象。i、 e.3月25日-付款1 3月25日-付款2、3月26日付款3、3月26日付款4、3月26日付款5等。 在我的get group视图方法中,我添加了一些逻辑,比如如果付款数据来自同一日期,那么它应该只属于该日期。 一切都很完美,只有当我向上滚动我的数据时,我的数据才会分散,也就是说,3月26日的记录将在3月25日之前

这是我的密码-

适配器-

public class PaymentAdapter extends BaseExpandableListAdapter implemen Filterable {
private LayoutInflater inflater;
private BaseActivity context;
private List<AdaptorData> dataAdaptor;
public String currentDate;
private List<AdaptorData> mStringFilterList;
ValueFilter valueFilter;

private String dateObj;

private ValueFilter mFilter = new ValueFilter();

public PaymentAdapter(final BaseActivity context, final List<AdaptorData> dataAdaptor) {
    this.context = context;
    this.dataAdaptor = dataAdaptor;
    this.mStringFilterList = dataAdaptor;
    inflater = LayoutInflater.from(context);
}

@Override
public int getGroupCount() {
    return dataAdaptor.size();
}

@Override
public int getChildrenCount(int groupPosition) {
    return 1;
}

@Override
public Object getGroup(int groupPosition) {

    return dataAdaptor.get(groupPosition);
}

@Override
public Object getChild(int groupPosition, int childPosition) {
    return 1;

}

@Override
public long getGroupId(int groupPosition) {

    return groupPosition;
}

@Override
public long getChildId(int groupPosition, int childPosition) {

    return childPosition;
}

@Override
public boolean hasStableIds() {

    return false;
}

@Override
public View getGroupView(int groupPosition, boolean isExpanded, final View convertView, ViewGroup parent) {
    ViewHolder holder;
    View adapterView = null;

    // if (convertView == null) {
    adapterView = inflater.inflate(R.layout.row_upcoming_or_recurring, parent, false);
    holder = new ViewHolder();
    adapterView.setTag(holder);
    // } else {
    // adapterView = convertView;
    // holder = (ViewHolder)adapterView.getTag();
    // }
    holder.textdate = (TextView)adapterView.findViewById(R.id.date_transaction);
    holder.paymentView = (RelativeLayout)adapterView.findViewById(R.id.payment_info_layout);
    holder.paymentTypeIndicator = (View)adapterView.findViewById(R.id.payment_type_indicator);
    holder.paymentName = (TextView)adapterView.findViewById(R.id.payment_name);
    holder.fromAccount = (TextView)adapterView.findViewById(R.id.from_account);
    holder.transactionAmountText = (TextView)adapterView.findViewById(R.id.payment_amount);
    holder.paymentTypeTextview = (TextView)adapterView.findViewById(R.id.recurring_or_upcoming);

    holder.textdate.setVisibility(View.GONE);
    holder.textdate.setClickable(false);
    if (currentDate != dataAdaptor.get(groupPosition).getDate()) {
        holder.textdate.setVisibility(View.VISIBLE);
        dateObj = DateTimeUtils.convertUnixTimeStampDate(Long.parseLong(dataAdaptor.get(groupPosition).getDate()), DateTimeUtils.DATE_FORMAT_SWEDISH);
        holder.textdate.setText(dateObj);
        currentDate = dataAdaptor.get(groupPosition).getDate();
    } else {
        holder.textdate.setVisibility(View.GONE);
    }

    holder.paymentView.setBackgroundColor(context.getResources().getColor(R.color.listitem_default));
    Details paymentInfo = dataAdaptor.get(groupPosition).getPayments().getDetails();
    int typeColor = R.color.economic_view_red;

    holder.paymentTypeIndicator.setBackgroundColor(context.getResources().getColor(typeColor));

    UiUtils.setPayerInfoText(context, holder.paymentName, dataAdaptor.get(groupPosition).getPayments());
    holder.paymentName.setTypeface(FontUtils.getFuturaHeavy());

    holder.fromAccount.setText(context.getString(R.string.PAYMNET_AND_TRANSFER_FROM_TEXT) + WebUtils.COLOM_STRING
            + FactoryUtils.getAccountNickName(context, dataAdaptor.get(groupPosition).getPayments().getThisAccount(), true, null));
    holder.fromAccount.setTypeface(FontUtils.getFuturaHeavy());

    holder.transactionAmountText.setTypeface(FontUtils.getFuturaHeavy());
    MonetaryAmount monetaryAmt = paymentInfo.getValue();
    String amount = monetaryAmt.getAmountValue().toString();
    holder.transactionAmountText.setText(UiUtils.getFormatedCurreancy(amount, context.getResources()));

    holder.paymentTypeTextview.setTextColor(context.getResources().getColor(typeColor));
    holder.paymentTypeTextview.setTypeface(FontUtils.getFuturaHeavy());
    holder.paymentTypeTextview.setText("Bank Transfer to another account");
    if (UiUtils.isEInvoiceActive(dataAdaptor.get(groupPosition).getPayments())) {
        holder.paymentEnvoice = (TextView)convertView.findViewById(R.id.payment_envoice);
        holder.paymentEnvoice.setTypeface(FontUtils.getFuturaHeavy());
        holder.paymentEnvoice.setVisibility(View.VISIBLE);
        holder.paymentEnvoice.setText("E-invoice");
    }

    return adapterView;
}

static class ViewHolder {
    TextView textdate;
    RelativeLayout paymentView;
    View paymentTypeIndicator;
    TextView paymentName;
    TextView fromAccount;
    TextView transactionAmountText;
    TextView paymentTypeTextview;
    TextView paymentEnvoice;

}

static class ViewchildHolder {
    TextView toView;
    TextView toValue;
    TextView balanceView;
    TextView balanceValue;
    TextView fromView;
    TextView fromValue;
    TextView dateView;
    TextView dateValue;
    TextView msgView;
    TextView msgValue;
}

@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View detailsLayout, ViewGroup parent) {
    ViewchildHolder holder;
    View row = null;
    // if (detailsLayout == null) {
    row = (LinearLayout)inflater.inflate(R.layout.payment_details, parent, false);
    holder = new ViewchildHolder();
    row.setTag(detailsLayout);
    // } else {`enter code here`
    // row = detailsLayout;
    // holder = (ViewchildHolder)row.getTag();
    // }

    holder.toValue = (TextView)row.findViewById(R.id.paymt_to_value);
    holder.balanceView = (TextView)row.findViewById(R.id.paymt_sum_view);
    holder.balanceValue = (TextView)row.findViewById(R.id.paymt_sum_value);
    holder.fromView = (TextView)row.findViewById(R.id.paymt_from_view);
    holder.fromValue = (TextView)row.findViewById(R.id.paymt_from_value);
    holder.dateView = (TextView)row.findViewById(R.id.paymt_date_view);
    holder.dateValue = (TextView)row.findViewById(R.id.paymt_date_value);
    holder.msgView = (TextView)row.findViewById(R.id.paymt_ocr_msg_view);
    holder.msgValue = (TextView)row.findViewById(R.id.paymt_ocr_msg_value);
    row.setBackgroundColor(context.getResources().getColor(R.color.listitem_detail_list));
    Details detail = dataAdaptor.get(groupPosition).getPayments().getDetails();
    holder.toView = (TextView)row.findViewById(R.id.paymt_to_view);
    holder.toView.setTypeface(FontUtils.getFuturaBook());

    Account toAccount = dataAdaptor.get(groupPosition).getPayments().getOtherAccount();

    holder.toValue.setTypeface(FontUtils.getFuturaHeavy());
    holder.toValue.setText(FactoryUtils.getAccountNickName(context, toAccount, false, detail.getDetailsType()));

    holder.balanceView.setTypeface(FontUtils.getFuturaBook());

    holder.balanceValue.setText(UiUtils.getFormatedCurreancy(detail.getValue().getAmountValue(), context.getResources()));
    holder.balanceValue.setTypeface(FontUtils.getFuturaHeavy());
    holder.balanceValue.setText(UiUtils.getFormatedCurreancy(detail.getValue().getAmountValue(), context.getResources()));
    Account fromAccount = dataAdaptor.get(groupPosition).getPayments().getThisAccount();

    holder.fromView.setTypeface(FontUtils.getFuturaBook());

    holder.fromValue.setTypeface(FontUtils.getFuturaHeavy());
    holder.fromValue.setText(FactoryUtils.getAccountNickName(context, fromAccount, false, null));

    holder.dateView.setTypeface(FontUtils.getFuturaBook());

    holder.dateValue.setTypeface(FontUtils.getFuturaHeavy());
    List<Action> actionList = detail.getActionsList();
    String strDate = actionList.get(0).getDate();
    String dateObj = DateTimeUtils.convertUnixTimeStampDate(Long.parseLong(strDate), DateTimeUtils.GENERAL_DATE_FORMAT);
    holder.dateValue.setText(dateObj);

    holder.msgView.setTypeface(FontUtils.getFuturaBook());

    holder.msgValue.setTypeface(FontUtils.getFuturaHeavy());
    if (detail.getMessage() != null) {
        holder.msgValue.setText(detail.getMessage());
        TransactionUtils.setMaxLine(detail.getMessage(), holder.msgValue);
    } else if (UiUtils.getLoginMethodType() == LoginMethodType.LOGIN_DEMO) {
        holder.msgValue.setText("Help");
    }`enter code here`

    return detailsLayout;
}

@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {

    return false;
}
公共类PaymentAdapter扩展BaseExpandableListAdapter实现Filterable{
私人充气机;
私人活动背景;
(私人名单)!和[这里]

此外,我还尝试了视图的setTag和视图的get tag。 该代码在代码中被注释。 但对我来说什么都不管用

有人能帮我吗?
如果您想了解更多信息,请告诉我。

我猜在设置日期时,这其中有逻辑错误。例如,在这段代码中,如果(currentDate!=DataAdapter.get(groupPosition).getDate(){holder.textdate.setVisibility(View.VISIBLE);dateObj=DateTimeUtils.ConvertunixtTimeStampdate(Long.parseLong)(DataAdapter.get(groupPosition).getDate()),DateTimeUtils.DATE_格式_瑞典语);holder.textdate.setText(dateObj);currentDate=DataAdapter.get(groupPosition).getDate();}其他{holder.textdate.setVisibility(View.GONE);}当向上滚动显示日期差异时,它将显示date我猜在设置日期时,这其中有逻辑错误。例如,在这段代码中,如果(currentDate!=DataAdapter.get(groupPosition).getDate(){holder.textdate.setVisibility(View.VISIBLE);dateObj=DateTimeUtils.ConvertUnixtTimeStampdate(Long.parseLong(DataAdapter.get(groupPosition.getDate()),DateTimeUtils.DATE_FORMAT_SWEDISH);holder.textdate.setText(dateObj);currentDate=DataAdapter.get(groupPosition.getDate();}否则{holder.textdate.setVisibility(View.GONE);}当向上滚动时,只要日期不同,就会显示该日期