Open kittusster opened 5 years ago
ublic class CustomAdapter extends RecyclerView.Adapter
private int current_item_position;
public static ArrayList<EditModel> editModelArrayList;
public CustomAdapter(Context ctx, ArrayList<EditModel> editModelArrayList){
inflater = LayoutInflater.from(ctx);
this.editModelArrayList = editModelArrayList;
}
@Override
public CustomAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = inflater.inflate(R.layout.rv_item, parent, false);
MyViewHolder holder = new MyViewHolder(view);
return holder;
}
@Override
public void onBindViewHolder(final CustomAdapter.MyViewHolder holder, final int position) {
holder.editText.setText(editModelArrayList.get(position).getEditTextValue());
holder.editTexts.setText(editModelArrayList.get(position).getEditttt());
holder.edchequedate.setText(editModelArrayList.get(position).getChequedate());
holder.edchequeamount.setText(editModelArrayList.get(position).getChequeamount());
holder.edchequeaccount.setText(editModelArrayList.get(position).getChequeaccount());
holder.edchequedate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//libin
showDate(1980, 0, 1, R.style.DatePickerSpinner);
/// edchequedate.setText(dob);
;
}
Calendar c = Calendar.getInstance();
/*public void showDate(int year, int monthOfYear, int dayOfMonth, int spinnerTheme) {
new SpinnerDatePickerDialogBuilder()
.context(itemView.getContext())
.callback(CustomAdapter.this)
.spinnerTheme(spinnerTheme)
.minDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH - 2), c.get(Calendar.DAY_OF_MONTH))
.defaultDate(year, monthOfYear, dayOfMonth)
.build()
.show();
}*/});
L11.setVisibility(View.VISIBLE);
L22.setVisibility(View.GONE);
L33.setVisibility(View.GONE);
editText.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editModelArrayList.get(getAdapterPosition()).setEditTextValue(editText.getText().toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
editTexts.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editModelArrayList.get(getAdapterPosition()).setEditttt(editTexts.getText().toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
edchequeamount.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editModelArrayList.get(getAdapterPosition()).setChequeamount(edchequeamount.getText().toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
edchequeaccount.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
}
@Override
public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
editModelArrayList.get(getAdapterPosition()).setChequeaccount(edchequeaccount.getText().toString());
}
@Override
public void afterTextChanged(Editable editable) {
}
});
//edchequedate.setText(dob);
}
}
@Override
public void onDateSet(com.tsongkha.spinnerdatepicker.DatePicker view, int year, int monthOfYear, int dayOfMonth) {
Calendar calendar = new GregorianCalendar(year, monthOfYear, dayOfMonth);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd/MM/yyyy", Locale.US);
dob = simpleDateFormat.format(calendar.getTime());
//libin
editModelArrayList.get(current_item_position).setChequedate(dob);
notifyItemChanged(current_item_position);
}
//libin public void showDate(int year, int monthOfYear, int dayOfMonth, int spinnerTheme) {
new SpinnerDatePickerDialogBuilder()
.context(itemView.getContext())
.callback(CustomAdapter.this)
.spinnerTheme(spinnerTheme)
.minDate(c.get(Calendar.YEAR), c.get(Calendar.MONTH - 2), c.get(Calendar.DAY_OF_MONTH))
.defaultDate(year, monthOfYear, dayOfMonth)
.build()
.show();
}
}
http://www.worldbestlearningcenter.com/tips/Android-pass-array-to-another-activity.htm