安卓将视图添加到ViewFlipper会导致java。StackOverflowerr语言
我想要一个有按钮的对话框
每当我点击一个特定的按钮,我希望对话框“翻转”并显示另一个布局。单击另一个按钮将返回到原始对话框的视图
我尝试按如下方式使用ViewFlipper:
XML:
发送反馈对话框。xml
<LinearLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:gravity="center"
安卓:orientation="vertical" >
<LinearLayout
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:orientation="horizontal" >
<TextView
安卓:id="@+id/TextView01"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
安卓:text="@string/feedback" />
</LinearLayout>
...
社交活动对话框。xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
安卓:id="@+id/main_activity_root"
安卓:layout_width="fill_parent"
安卓:layout_height="fill_parent"
安卓:background="@安卓:color/transparent" >
<ViewFlipper
安卓:id="@+id/viewFlipper"
安卓:layout_width="300dp"
安卓:layout_height="407dp"/>
<RelativeLayout
安卓:id="@+id/main_activity_card_face"
安卓:layout_width="300dp"
安卓:layout_height="407dp"
安卓:layout_centerHorizontal="true"
安卓:layout_centerVertical="true"
安卓:background="@安卓:color/white"
安卓:clickable="true"
安卓:onClick="onCardClick"
安卓:padding="5dp" >
<LinearLayout
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:gravity="center"
安卓:orientation="vertical" >
...
代码:
final ViewFlipper viewFlipper = (ViewFlipper) mDialog
.findViewById(R.id.viewFlipper);
View feedbackview = View.inflate(mContext,
R.layout.send_feedback_dialog, viewFlipper);
// ((ViewGroup)
// feedbackview.getParent()).removeView(feedbackview);
// viewFlipper.addView(feedbackview);
// View socialActions = View.inflate(mContext,
// R.layout.social_actions_dialog, viewFlipper);
// ((ViewGroup) socialActions.getParent())
// .removeView(socialActions);
// viewFlipper.addView(socialActions);
private void flipDialog(ViewFlipper viewFlipper,
boolean isSocialActionsShown, AlphaAnimation alphaIn,
AlphaAnimation alphaOut) {
if (isSocialActionsShown) {
isSocialActionsShown = false;
viewFlipper.setInAnimation(alphaIn);
viewFlipper.setOutAnimation(alphaOut);
// Show the next Screen
viewFlipper.showNext();
} else {
isSocialActionsShown = true;
viewFlipper.setInAnimation(alphaIn);
viewFlipper.setOutAnimation(alphaOut);
viewFlipper.showPrevious();
}
}
我曾经得到java.lang.StackOverflowError
,然后我对一些行进行了注释,现在执行翻转,但没有任何更改
我怎样才能使它正常工作
在不同文件中组织对话框布局的正确方法是什么
我曾尝试在不同的文件中创建该对话框,但它需要很多东西,也许最好将其用作内部类
共 (0) 个答案