2017-08-29 2 views
0

Ich habe versucht, die Ansicht RecyclerView hinzuzufügen, wenn Sie auf Button in einer ViewHolder klicken.Ansicht in RecyclerView hinzufügen

enter image description here

Wenn Klick auf Button in ViewHolder3, eine Ansicht (mehr hinzufügen) fügt und oben wie Bild erscheinen.

ViewAddMore wird dort pin und RecyclerView kann normal scrollen.

Ich habe versucht, aber keine Lösung für mein Problem gefunden; Haben Sie Vorschläge für mein Problem?

+0

Also, wo willst du das ViewAddMore sehen? – Raghavendra

+0

@Raghavendra: Es ist dynamisch. Wenn der Benutzer auf 'Button' klickt, erscheint ein ViewAddMore über' ViewHolder1' und 'ViewHolder2'. –

+0

Ich würde vorschlagen, dass Sie das nicht tun. Es ist wirklich schlechtes Design, um Ihre RecyclerViews Ansicht nach einem Popup-Fenster zu blockieren. –

Antwort

0

Verwenden Sie PopupWindow, um diese Ansicht anzuzeigen.

// get a reference to the already created main layout 
    LinearLayout mainLayout = (LinearLayout) findViewById(R.id.activity_main_layout); 

    // inflate the layout of the popup window 
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE); 
    View popupView = inflater.inflate(R.layout.popup_window, null); 

    // create the popup window 
    int width = LinearLayout.LayoutParams.WRAP_CONTENT; 
    int height = LinearLayout.LayoutParams.WRAP_CONTENT; 
    boolean focusable = true; // lets taps outside the popup also dismiss it 
    final PopupWindow popupWindow = new PopupWindow(popupView, width, height, focusable); 

    // show the popup window 
    popupWindow.showAtLocation(mainLayout, Gravity.CENTER, 0, 0); 

    // dismiss the popup window when touched 
    popupView.setOnTouchListener(new View.OnTouchListener() { 
     @Override 
     public boolean onTouch(View v, MotionEvent event) { 
      popupWindow.dismiss(); 
      return true; 
     } 
    }); 
  1. https://developer.android.com/reference/android/widget/PopupWindow.html

  2. How to make a simple android popup window?

Hope this Ihnen helfen.

Verwandte Themen