开发者

viewflipper not calling onCreate of page

开发者 https://www.devze.com 2023-02-16 16:47 出处:网络
I am new to Android development.I would like to use the viewflipper to bring in pages of my application.It would go to the next or previous page depending on the recieved gesture event.I have the gest

I am new to Android development. I would like to use the viewflipper to bring in pages of my application. It would go to the next or previous page depending on the recieved gesture event. I have the gesture working and pages scroll in and out. Cool! Problem: the onCreate of each page 开发者_Go百科doesn't fire and hence I have no click events defined. Here's what I got:

private void BuildViewFlipper(ViewFlipper flipper)
{
    views = new View[2];

    views[0] = GetView(R.layout.ivdosage);

    flipper.addView(views[0], 0);
    views[0].setOnClickListener(CalculationViewer.this); 
    views[0].setOnTouchListener(gestureListener);

    views[1] = GetView(R.layout.ivrate);
    flipper.addView(views[1], 1);
    views[1].setOnClickListener(CalculationViewer.this); 
    views[1].setOnTouchListener(gestureListener);

    flipper.setDisplayedChild(viewIndex); 
}


private View GetView(int id){
    LayoutInflater inflater = this.getLayoutInflater();
    View view = inflater.inflate(id, null);        

    return view;
}

The views in the above code were Activities. What am I missing? Any help would be greatly appreciated!

  • Craig

PS: The fixed array for the views was to just get me going and will be updated later. :)


ViewFlipper can only host views. You can't include an entire activity in a ViewFlipper.

This is a common question.

0

精彩评论

暂无评论...
验证码 换一张
取 消