2016-09-01 11 views
1

enter image description here は私がフラグメントでRecyclerViewを持っていると私は以下のユーザー押しボタンが「新しい行を追加」するとき、それはここまで、新しいフラグメントにリダイレクトされますしたいテキスト編集コンテンツからRecyclerViewリストを作成します。しかし、今私はrecyclerView内の行を追加することができ、動的にも削除すべての行のクロス右上がありますが、ユーザの上の画像で見ることができるように形に充填詳細はrecyclerviewに新しい行として私はそれを達成することができます問題はありません

が表示されますしたいですリストから行。

だから、私は何をしたいのか

1)は、私は、ユーザー押しするとすぐに、フォーム入力を持つリストに行を追加することができますどのようにして、ユーザー新しく追加された行を表示保存イベントである彼私は、フォームでのユーザー入力でリストから動的に行を追加しても

+0

アダプタ – lelloman

+0

上など、私が知っている事をあなたのリストを更新したり、アダプタが使用しているものは何でも、コンテナ、その後notifyDataSetChanged(コール)またはnotifyItemChanged notifyItemInsertedが、どのように – androidXP

+0

フォームデータとのリストを更新するために、関連するコード – lelloman

答えて

0

は、私は、行項目の右上にユーザープレス十字ボタンをSOLVとき、リストから削除したい要するに

形式で詳細を入力ED私は(フォームを持っている)fragment_2から(recyclerviewを有する)fragment_1し、結果を送信するためにinterfaceを作成する私は2番目のフラグメント まずから戻って最初のフラグメントにデータを取得するためにやった自分でこの問題

は、ここに私のフォームコードです

@Override 
    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(R.id.PPL_Spinner); 
     Title= (EditText) view.findViewById(R.id.ppl_title); 
     Address= (AutoCompleteTextView) view.findViewById(R.id.ppl_address); 
     Year= (EditText) view.findViewById(R.id.ppl_passing_year); 
     Description= (EditText) view.findViewById(R.id.ppl_description); 
     btn1= (Button) view.findViewById(R.id.ppl_map_button); 

     Save= (Button) view.findViewById(R.id.ppl_save); 
     Save_PPL.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       title=Title.getText().toString(); 
       address= Address.getText().toString(); 
       year=Year.getText().toString(); 
       description=Description.getText().toString(); 
       //PPL Wrapper 
       PPL_list_wrapper list=new PPL_list_wrapper(title,year,address); 

       Add_PPL=(PPL_transfer_data_to_list)getActivity(); 
       Add_PPL.addLocation(list); 
       fragment_1 fragment1=new fragment_1(); 
       FragmentTransaction fragmentTransaction=getFragmentManager().beginTransaction(); 
       fragmentTransaction.replace(R.id.Navigation_Main_Layout,fragment1); 
       fragmentTransaction.commit(); 

      } 
     }); 


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

し、私は、親アクティビティにinfterfaceを実装し、この

@Override 
    public void addEvent(PPL_list_wrapper PPL_DATA) { 
     fragment_1 recycler=new fragment_1(); 
     recycler.PPL_eve(PPL_DATA); 

    } 

T様活性からメソッドを呼び出すfragment_1鶏私はfragment_1にデータを取得し、静的リストなしの断片static原因でのArrayListをしなければならないが、あまりにもその参照やデータを失ったし、それはrecyclerview

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

    } 

にデータの表示を停止します私は私のリストが静的であることを確認する必要があります

static List<PPL_list_wrapper> event_details=new ArrayList<PPL_list_wrapper>(); 
関連する問題