Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom View Group using Fragments #36

Closed
zachtom opened this issue Oct 28, 2014 · 2 comments
Closed

Custom View Group using Fragments #36

zachtom opened this issue Oct 28, 2014 · 2 comments

Comments

@zachtom
Copy link

zachtom commented Oct 28, 2014

I am trying to use a custom view group with cover flow. Instead of an XML layout or view , I am trying to load the view from fragment transaction. Here is the code I am trying to use here,

@OverRide

public View getCoverFlowItem(int i, View reuseableView, ViewGroup viewGroup) {
CustomViewGroup fancyView = null;
if (reuseableView != null) {
fancyView = (CustomViewGroup) reuseableView;
} else
{
fancyView = new CustomViewGroup(context);
fancyView.getFrameLayout().setId(i+10000);
fancyView.setLayoutParams(new FancyCoverFlow.LayoutParams(750, ViewGroup.LayoutParams.WRAP_CONTENT));
}

    FragmentManager fragmentManager = manager;
    FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    fragmentTransaction.add(fancyView.getFrameLayout().getId(), ItemFragment.init(i));
    fragmentTransaction.commit();





    return fancyView;
}

class CustomViewGroup extends LinearLayout {

    // =============================================================================
    // Child views
    // =============================================================================

    private FrameLayout frameLayout;



    // =============================================================================
    // Constructor
    // =============================================================================

    private CustomViewGroup(Context context) {
        super(context);

        this.setOrientation(VERTICAL);

        this.frameLayout = new FrameLayout(context);

        LinearLayout.LayoutParams layoutParams = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
        this.frameLayout.setLayoutParams(layoutParams);





        this.addView(this.frameLayout);
    }

    // =============================================================================
    // Getters
    // =============================================================================

    private FrameLayout getFrameLayout() {
        return frameLayout;
    }
}    

For me the issue is the getView function is getting called infinite number of times for value i=0. But If I don't commit a fragment transaction it works normal(ie getting called only once for index 0)

Any clue on whats happening here?

Thanks

@davidschreiber
Copy link
Owner

Sorry but I no longer maintain this project. I will still keep this project as reference for future visitors but I highly recommend to implement the coverflow itself using Android's new RecyclerView.

@davidschreiber
Copy link
Owner

This project is no longer maintained. Feel free to fork it and to improve upon it. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants