RecyclerView recyclerView;
List<Object> list;
RecycleAdapter recycleAdapter;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
recyclerView = rootView.findViewById(R.id.recyclerview);
list = new ArrayList<>();
Button send= rootView.findViewById(R.id.button);
final EditText editText = rootView.findViewById(R.id.editText);
send.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
list.add(0,editText.getText().toString());
recycleAdapter.notifyDataSetChanged();
}
});
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity(), LinearLayout.VERTICAL,true));
recycleAdapter = new RecycleAdapter(getActivity(), list);
recyclerView.setAdapter(recycleAdapter);
return rootView;
}