when i click on the text the app crashes and error appears in the line below mentioned.
public class DataHolder extends RecyclerView.ViewHolder {
public TextView table;
int tableData;
public DataHolder(final View itemView) {
super(itemView);
table = (TextView) itemView.findViewById(R.id.table_list);
table.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Log.d("ashu", "onClick: is called");
tableData = Integer.parseInt(table.getText().toString());
Context context = view.getContext();
Intent intent = new Intent(context, RecyclerAdapterNew.class);
intent.putExtra("transfer", tableData);
Log.d("ashu", "last lone is to be executed");
context.startActivity(intent);//error in this line
}
});
}
}
my second class is this in which i have to pass the value through the putExtra but the app crashes in the previous Activity when i click my text
public class RecyclerAdapterNew extends RecyclerView.Adapter<DataHolderNew> {
int tableData;
@Override
public DataHolderNew onCreateViewHolder(ViewGroup parent, int viewType) {
Context context = parent.getContext();
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.table_values, parent, false);
Intent intent = ((Activity) context).getIntent();
tableData = intent.getIntExtra("transfer", tableData);
return new DataHolderNew(view);
}
@Override
public void onBindViewHolder(DataHolderNew holder, int position) {
holder.table_value.setText((position + 1) * tableData);
}
@Override
public int getItemCount() {
return 10;
}
}