androidXP androidXP - 1 month ago 5
Java Question

Create RecyclerView List From Edit Text Content

enter image description here
I have RecyclerView in fragment and i want when user press button below "Add New Row" it will redirect to new fragment till here there is no problem i can achieve it but now i want the details filled in form will show as new row in recyclerview

As you can see in image above user can add row in RecyclerView dynamically and also there is cross top right of every row which delete row from list.

So,What i want to do is

1) How i can add row to the list with form inputs as soon as user press Save Event then show user newly added row with his entered details in form

In short i want to add row dynamically from list with user inputs in form and also delete it from list when user press cross button at top right of row item


I solved this issue by myself what i did to get data back into first fragment from second fragment First i create interface to send result to fragment_1(Which has recyclerview) from fragment_2(Which has form)

Here is my form code

    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view=inflater.inflate(R.layout.ppl_details_form,container,false);
        PPL_Title_Spinner= (Spinner) view.findViewById(;
        Title= (EditText) view.findViewById(;
        Address= (AutoCompleteTextView) view.findViewById(;
        Year= (EditText) view.findViewById(;
        Description= (EditText) view.findViewById(;
        btn1= (Button) view.findViewById(;

        Save= (Button) view.findViewById(;
        Save_PPL.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                address= Address.getText().toString();
                //PPL Wrapper
                PPL_list_wrapper list=new PPL_list_wrapper(title,year,address);

                fragment_1 fragment1=new fragment_1();
                FragmentTransaction fragmentTransaction=getFragmentManager().beginTransaction();


    public void onAttach(Context context) {
            Add_PPL= (PPL_transfer_data_to_list) context;
        catch (ClassCastException e){
            throw new ClassCastException(getActivity().toString()+" Must Implement Interface");

And then i implement infterface into Parent Activity and then call fragment_1 method from activity like this

    public void addEvent(PPL_list_wrapper PPL_DATA) {
        fragment_1 recycler=new fragment_1();


Then i get data into fragment_1 and have to make arraylist in fragment static cause without static list will lost its reference and data too and it will stop showing data into recyclerview

 public void PPL_eve(final PPL_list_wrapper ppl_list_wrapper){
        event_details.add(ppl_list_wrapper);//Static ArrayList
        adapter=new ppl_Recycler_Adapter(getActivity(),event_details);


I have to make sure that my list is static

static List<PPL_list_wrapper> event_details=new ArrayList<PPL_list_wrapper>();