I am displaying the Data in to ListView as like below code:
private class OrderAdapter extends ArrayAdapter<Employer> {
private ArrayList<Employer> items;
public OrderAdapter(Context context, int textViewResourceId, ArrayList<Employer> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.paye_list_row, null);
}
Employer o = items.get(position);
if (o != null) {
TextView tt = (TextView) v.findViewById(R.id.toptext);
TextView bt = (TextView) v.findViewById(R.id.value);
if (tt != null) {
tt.setText(o.getOrderName()); // Setting the Value here
}
if(bt != null){
if(position==0)
bt.setText(o.getTaxcode()); // Setting the Value here
if(position==1)
bt.setText(o.getPayPeriod()); // Setting the Value here
if(position==2)
bt.setText(o.getPayFrequency()); // Setting the Value here
if(position==3)
bt.setText(o.getSalaryWage()); // Setting the Value here
if(position==4)
bt.setText(o.getNetGrossAmount()); // Setting the Value here
if(position==5)
bt.setText(o.getKiwiSaverMember()); // Setting the Value here
if(position==6)
bt.setText(o.getEmployeeDeduction()); // Setting the Value here
if(position==7)
bt.setText(o.getEmployeeContribution()); // Setting the Value here
if(position==8)
bt.setText(o.getComplyingFundMember()); // Setting the Value here
if(position==9)
bt.setText(o.getFundContribution()); // Setting the Value here
if(position==10)
bt.setText(o.getESCTTaxRate()); // Setting the Value here
if(position==11)
bt.setText(o.getChildSupportDeduction()); // Setting the Value here
if(position==12)
bt.setText(o.getPayrollDonation()); // Setting the Value here
}
}
return v;
}
}
And i am adding the data manualy to my another ArrayList like below code:
// Set Employee one by one
ArrayList<Employer> tempEmployerList = employerList;
System.out.println("=================================" +
"=IN end Document================================");
System.out.println(" tempEmployerList Size:" +tempEmployerList.size());
Employer m = new Employer();
// My Code for to add data
m = new Employer();
m.setTaxcode(taxCodeValue);
m.setPayPeriod(payPeriodValue);
m.setPayFrequency(payFrequencyValue);
m.setSalaryWage(salaryWageValue);
m.setNetGrossAmount("Gross");
m.setKiwiSaverMember(kiwiSaverMemberValue);
m.setEmployeeDeduction(employeeDeductionValue);
m .setEmployeeContribution(employeeContributionValue);
m.setComplyingFundMember(complyingFundMemberValue);
m.setFundContribution(fundContributionValue);
m.setESCTTaxRate(ESCTTaxRateValue);
m.setChildSupportDeduction(childSupportDeductionValue);
m.setPayrollDonation(payrollDonationValue);
employerList.add(m);
If I want to display that data in log cat then i can see it by below code:
// TO DISPLAY DATA
for(int j=0;j<tempEmployerList.size();j++)
{
System.out.println("================ Employee: "+(j+1)+"======================");
m = new Employer();
m=tempEmployerList.get(j);
//System.out.println("TaxCodeHeading: "+(j+1)+" = "+m.getOrderName());
System.out.println("TaxCode: "+(j+1)+" = "+m.getTaxcode());
System.out.println("PayPeriod: "+(j+1)+" = "+m.getPayPeriod());
System.out.println("Frequency: "+(j+1)+" = "+m.getPayFrequency());
System.out.println("Salary/Wage: "+(j+1)+" = "+m.getSalaryWage());
System.out.println("NetGross Amount: "+(j+1)+" = "+m.getNetGrossAmount());
System.out.println("KiwiSaverMember: "+(j+1)+" = "+m.getKiwiSaverMember());
System.out.println("Employee Deduction: "+(j+1)+" = "+m.getEmployeeDeduction());
System.out.println("Complying Fund Member: "+(j+1)+" = "+m.getComplyingFundMember());
System.out.println("Fund Contribution: "+(j+1)+" = "+m.getFundContribution());
System.out.println("ESCT Tax Rate: "+(j+1)+" = "+m.getESCTTaxRate());
System.out.println("Child Support Deduction: "+(j+1)+" = "+m.getChildSupportDeduction());
System.out.println("Payroll giving Donation: "+(j+1)+" = "+m.getPayrollDonation());
}
All Works fine. But now if i have added more then one employee then i want to display it on the List view one by one on the click of the next button click.
So how it is Possible.
Please help me for that.
Thanks.
Declare an Employee Object as a Field in Activity, and load your adapter data from that field, in case of next and previous button event change Employer object to next or previous item in list and call adapter.notifyDataSetChanged() method.