1

I have a StackView widget in my App. Basically I created this widget using the tutorial at How to create a StackView widget and modified it a bit for my needs.

Now I want to get the top element for calling a function with this element as soon as the user changes the top element. The user can "swipe" down or swipe up, but how can I get the top shown element on the stack?

At the moment I do it in the factories-getViewAt-function, using something like:

Integer topPosition = 0;
if(getCount() > position+1) {
    topPosition = position+1;
}
MyModel myModel = mMyModels.get(topPosition);
activateMyModel(myModel);

But this only works if the user swipes from down to up. If the user swipes from up to down, this code won't work, because the topPosition is not correct for this.

I searched a lot for a solution but could not find any. I tried to create my own StackView extending the original StackView, too, but this seems not to work if I want to use it as a Widget on my devices home screen.

Do you have any ideas how to do this?

RiPr
  • 11
  • 5

0 Answers0