Problem with DialogFragment on Android?


I am trying to develop an application that looks like a feed news where the information is obtained from a json that is in a host , from there I can add and modify the data, the information is displayed in a cardview the problem is that I want to make click on one of them open the item and show the information complete, for the moment I try to do it with a DialogFragment in this way


  new MyRecyclerAdapter.RecyclerTouchListener(
    getApplicationContext(), recyclerView, new MyRecyclerAdapter.ClickListener() {
public void onClick(View view, int position) {
    Bundle bundle = new Bundle();
    bundle.putSerializable("images", datos);
    bundle.putInt("position", position);

    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    Detalles newFragment = Detalles.newInstance();
    newFragment.setArguments(bundle);, "slideshow");

public class Detalles extends DialogFragment{
    private String TAG = Detalles.class.getSimpleName();
    private ArrayList<NewsFeed> datos;
    private TextView tituloon, notoon;

    private View viewPager;

     private MyViewPagerAdapter myViewPagerAdapter;
        private int selectedPosition = 0;
    static Detalles newInstance() {
        Detalles f = new Detalles();
        return f;

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.detalles_completo, container, false);
        tituln = (TextView) v.findViewById(;
        notlnn = (TextView) v.findViewById(;
        datos = (ArrayList<NewsFeed>) getArguments().getSerializable("images");
         myViewPagerAdapter = new MyViewPagerAdapter();

        selectedPosition = getArguments().getInt("position");

        return v;
    private void displayMetaInfo(int position) {

        NewsFeed image = datos.get(position);
    public void onCreate(Bundle savedInstanceState) {
    public class MyViewPagerAdapter extends PagerAdapter {

        private LayoutInflater layoutInflater;

        public MyViewPagerAdapter() {

        public Object instantiateItem(ViewGroup container, int position) {

            layoutInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            View view = layoutInflater.inflate(R.layout.detalles_completo, container, false);

            NewsFeed image = datos.get(position);



            return view;
        public int getCount() {
            return datos.size();
        public boolean isViewFromObject(View view, Object obj) {
            return view == ((View) obj);
        public void destroyItem(ViewGroup container, int position, Object object) {
            container.removeView((View) object);


With this when click in the cardview achievement that the DialogFragment is opened, but only shows the text that is by default in the layout , the GetFeedname does not work . I know that the code has a lot of errors and it is because I try to implement an example that I found out there, I await your advice.

asked by SpaceSpace 10.11.2016 в 21:03

1 answer


Apparently you forgot to invoke the displayMetaInfo method from onCreateView. With that, it will show the values.

answered by 11.11.2016 в 00:50