Problem with DialogFragment on Android?

2

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

MainActivity

recyclerView.addOnItemTouchListener(
  new MyRecyclerAdapter.RecyclerTouchListener(
    getApplicationContext(), recyclerView, new MyRecyclerAdapter.ClickListener() {
@Override
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);
    newFragment.show(ft, "slideshow");
}

Details.java

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(R.id.titulon);
        notlnn = (TextView) v.findViewById(R.id.noton);
        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);
        tituln.setText(image.getFeedName());
        notlnn.setText(image.getContent());
    }
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }
    public class MyViewPagerAdapter extends PagerAdapter {

        private LayoutInflater layoutInflater;

        public MyViewPagerAdapter() {
        }

        @Override
        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);

            tituln.setText(image.getFeedName());

            container.addView(view);

            return view;
        }
        @Override
        public int getCount() {
            return datos.size();
        }
        @Override
        public boolean isViewFromObject(View view, Object obj) {
            return view == ((View) obj);
        }
        @Override
        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
source

1 answer

1

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

    
answered by 11.11.2016 в 00:50