Closed alahammad closed 11 years ago
I just want to make sure I'm understanding correctly.
You are setting a tag on a list item in the getView method? Then you are trying to retrieve the tag in your activity?
Where is the NullPointerException happening?
yes that what i am doing .. NullPointerException when getTag in activity .
Can you post the code where you set the tag and where you retrieve the tag
here where i set tag : @Override public View getItemView(final int section, final int position, View convertView, ViewGroup parent) { LinearLayout layout = null; ViewHolder holder = null; TextView loanId, payment, emi, amount; CheckBox loanCheckBox; if (convertView == null) { LayoutInflater inflater = (LayoutInflater) parent.getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = (LinearLayout) inflater.inflate( R.layout.loan_row_select, null); loanId = (TextView) convertView.findViewById(R.id.tv_loan_id); payment = (TextView) convertView.findViewById(R.id.tv_loan_payment); emi = (TextView) convertView.findViewById(R.id.tv_loan_emi); amount = (TextView) convertView.findViewById(R.id.tv_loan_amount); loanCheckBox = (CheckBox) convertView .findViewById(R.id.iv_checked_loan); holder = new ViewHolder(loanId, payment, emi, amount, loanCheckBox); convertView.setTag(holder); loanCheckBox.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
CheckBox cb = (CheckBox) v;
LoanOverView planet = (LoanOverView) v.getTag();
planet.setChecked(cb.isChecked());
}
});
} else {
// convertView = (LinearLayout) convertView;
holder = (ViewHolder) convertView.getTag();
loanCheckBox = holder.getLoanCheckBox();
loanId = holder.getLoanId();
payment = holder.getPayment();
emi = holder.getEmi();
amount = holder.getAmount();
}
LoanOverView loanOverView = (LoanOverView) items.get(
mHeaders.get(section)).get(position);
loanId.setText(CastUtil.objectToString(loanOverView.AccountNumber));
payment.setText(mContext.getString(R.string.pay_row_1) + " "
+ CastUtil.objectToString(loanOverView.MinimumPayment));
emi.setText(mContext.getString(R.string.pay_row_2) + " "
+ CastUtil.objectToString(loanOverView.EMI));
amount.setText(mContext.getString(R.string.pay_row_3) + " "
+ CastUtil.objectToString(loanOverView.TotalAmountDue));
loanCheckBox.setTag(loanOverView);
loanCheckBox.setChecked(loanOverView.isChecked());
return convertView;
}
and here where i get tag :
@Override
public void onItemClick(SectionedBaseAdapter adapter, View view,
int section, int position, long id) {
items = new ArrayList
Hi jimi, when setTag in getView function and return it from activity return null ?! can check what happend . sorry i don't have log just null pointer exception ..