I know there is a way to scroll to the bottom of a RecyclerView from Activities, but is there any way I can scroll to the bottom of a RecyclerView from the Adapter? I want to scroll to the bottom when an EditText is focused upon.
Here is some of my Adapter where I would like to scroll to the bottom of the RecyclerView.
@Override public void onBindViewHolder(final ViewHolder holder, final int i) { final int position = holder.getAdapterPosition(); updatePrefs(); holder.editTextListener.updatePosition(position); holder.studentText.setHint(mDataset.get(position)); holder.studentNumber.setText(position + 1 + "."); if (position != 0) { holder.studentText.setOnFocusChangeListener(new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { if (hasFocus) { holder.studentText.setHint(v.getContext().getResources() .getString(R.string.prompt_student_name)); setDeleteListener(holder.studentDelete, position); holder.studentText.setOnFocusChangeListener(null); mDataset.add(v.getContext().getResources() .getString(R.string.prompt_new_student_name)); notifyItemInserted(position + 1); //SCROLL TO BOTTOM OF RECYCLERVIEW } } }); } //Check to make sure they're not deleting their only way of adding a new EditText if (!holder.studentText.getHint().equals(holder.studentText.getContext().getResources() .getString(R.string.prompt_new_student_name))) { setDeleteListener(holder.studentDelete, position); } }
((Activity) context).findViewById(R.id.recyclerView)and scroll method over it didn't work?