I am using listview and i am displaying json response to my listview,i am displaying price from json in my listview,so when i check checkbox,the price selected list item want to store in array list,following is my code can any one help
public class CustomAdapterPooja extends BaseAdapter {
private LayoutInflater inflater=null;
Context context;
private ArrayList<HashMap<String,String>> listData;
private static final String TAG_POOJA_NAME="pooja_name";
private static final String TAG_POOJA_AMOUNT="amount";
private static final String TAG_POOJA_DAYS="worship";
Calendar newCalendar = Calendar.getInstance();
public CustomAdapterPooja(FragmentActivity mainActivity, ArrayList<HashMap<String,String>> listData) {
// TODO Auto-generated constructor stub
context = mainActivity;
this.listData=listData;
inflater = ( LayoutInflater )context.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return listData.size();
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public class Holder
{
TextView tv;
TextView serviceprice;
public CheckBox checks;
public TextView dayss;
public ImageView seledates;
public TextView txtseledates;
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
final Holder holder=new Holder();
String rup="\u20B9";
View rowView;
rowView = inflater.inflate(R.layout.list_item_poojaselection, null);
holder.tv=(TextView) rowView.findViewById(R.id.list_item_poojaname);
holder.serviceprice=(TextView)rowView.findViewById(R.id.list_item_poojaprice);
holder.dayss=(TextView)rowView.findViewById(R.id.list_item_poojadays);
holder.seledates=(ImageView)rowView.findViewById(R.id.list_item_selectdates);
holder.txtseledates=(TextView)rowView.findViewById(R.id.selecteddatess);
holder.checks=(CheckBox)rowView.findViewById(R.id.list_item_poojacheck);
holder.checks.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
System.out.println("hello"+listData.get(position).get(TAG_POOJA_AMOUNT));
}
});
holder.seledates.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
datePickerDialog.show();
}
});
holder.tv.setText(listData.get(position).get(TAG_POOJA_NAME));
holder.dayss.setText(listData.get(position).get(TAG_POOJA_DAYS));
holder.serviceprice.setText(rup + listData.get(position).get(TAG_POOJA_AMOUNT));
datePickerDialog = new DatePickerDialog(getActivity(), new DatePickerDialog.OnDateSetListener() {
@Override
public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
sYear = year;
sMonth = monthOfYear;
sDate = dayOfMonth;
holder.txtseledates.setText(new StringBuilder()
// Month is 0 based, just add 1
.append(sYear).append("-").append(sMonth + 1).append("-").append(sDate));
/*selecdts=textcal.getText().toString();
System.out.println("Selected dtes"+selecdts);*/
}
}, newCalendar.get(Calendar.YEAR), newCalendar.get(Calendar.MONTH), newCalendar.get(Calendar.DAY_OF_MONTH));
datePickerDialog.getDatePicker().setMinDate(System.currentTimeMillis() - 1000);
return rowView;
}
}
Aucun commentaire:
Enregistrer un commentaire