2017-01-25 6 views

答えて

1

この試してみてください:あなたはDialogFragmentを拡張し、リサイクルを眺めることができますカスタムダイアログを作成する必要があります

custom_dialog.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content"> 

    <android.support.v7.widget.RecyclerView 
    android:id="@+id/my_recycler_view" 
    android:scrollbars="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 
</LinearLayout> 

アクティビティ/ Fragment.java

RecyclerView mRecyclerView; 
AlertDialog.Builder builder = new AlertDialog.Builder(context); 
LayoutInflater inflater = LayoutInflater.from(context); 
View content = inflater.inflate(R.layout.custom_dialog, null); 
builder.setView(content); 
mRecyclerView = (RecyclerView) content.findViewById(R.id.my_recycler_view); 
1

をその中に。

レイアウト: - fragment_dialog.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <android.support.v7.widget.RecyclerView 
    android:id="@+id/recycler_view" 
    android:scrollbars="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"/> 

</RelativeLayout> 

カスタムダイアログ: - MyDialogFragment

public class MyDialogFragment extends DialogFragment { 
    private RecyclerView mRecyclerView; 
    // this method create view for your Dialog 
    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
      //inflate layout with recycler view 
     View v = inflater.inflate(R.layout.fragment_dialog, container, false); 
     mRecyclerView = (RecyclerView) v.findViewById(R.id.recycler_view); 
     //setadapter 
     //get your recycler view and populate it. 
     return v; 
    } 
} 
関連する問題