Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
package com.mako.companyname;
import android.content.Context;
import android.content.Intent;
import android.support.v4.app.FragmentActivity;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import java.util.List;
/**
* Created by Mako on 2/9/2017.
*/
public class formadapter extends RecyclerView.Adapter <formadapter.ViewHolder> {
private List<Order> dataset;
private String formtype;
String type;
Context context;
public formadapter(List<Order> dataset, FragmentActivity activity, String formType) {
this.dataset =dataset;
this.context=activity;
this.formtype=formType;
}
@Override
public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.form_item, parent, false);
return new formadapter.ViewHolder(view);
}
@Override
public void onBindViewHolder(formadapter.ViewHolder holder, int position) {
holder.tx.setText(dataset.get(position).getBuyer());
holder.seller.setText(""+dataset.get(position).getNum());
holder.date.setText(getDate(dataset.get(position).getBilldate()));
holder.money.setText("Rs "+dataset.get(position).getActualamt());
}
public String getDate(int date){
int year=2000,month=00,day=00;
day=date%100;
date=date/100;
month=date%100;
date=date/100;
year=year+date;
return ""+day+"/"+month+"/"+year;
}
@Override
public int getItemCount() {
return dataset.size();
}
public class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
private TextView tx,seller,date,money,invoice;
public ViewHolder(View view) {
super(view);
tx = (TextView) view.findViewById(R.id.buyer_name_tx);
seller=(TextView)view.findViewById(R.id.number);
date=(TextView)view.findViewById(R.id.date);
money=(TextView)view.findViewById(R.id.amt);
view.setOnClickListener(this);
}
@Override
public void onClick(View v) {
Intent intent = new Intent(context,addforms.class);
intent.putExtra("type",formtype);
intent.putExtra("input",dataset.get(getLayoutPosition()));
intent.putExtra("key",dataset.get(getLayoutPosition()).getBuyerKey());
context.startActivity(intent);
}
}
}
@ashesh404
Copy link

ashesh404 commented Mar 27, 2018

hi,i need your addforms.java file ,please upload it.
or my email:parmarashesh40@gmail.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment