如何在AlertDialog打开的情况下更新FrameLayout?

时间:2014-10-03 01:05:20

标签: android views refresh visibility android-framelayout

我需要更新文本视图,并使用在AlertDialog上输入的文本将其显示,问题是,在更新后从GONE更改为VISIBLE我想将FrameLayout保存为图像,并共享此内容。我的代码正在执行此操作并且它正在工作,但是,因为FrameLayout的AlertDialog仅在Dialog之后刷新(我需要在此侦听器中刷新并保存,再次更改为GONE),我该怎么办?已经尝试过.invalidate(),requestLayout()和.postInvalidate()...而.setOnDismissListener只来自API17。

这是代码:

fl是我的frameLayout

public void actionShare(View v){
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("What was the question ?");

    final EditText input = new EditText(this);
    input.setInputType(InputType.TYPE_CLASS_TEXT);

    builder.setView(input);

    // Set up the buttons
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { 
        @Override
        public void onClick(DialogInterface dialog, int which) {
            m_Text = "Question: " + input.getText().toString();
            tvQuestion.setText(m_Text);
            shareViewsVisible(true);
            fl.invalidate();
            fl.requestLayout();
            fl.postInvalidate();
            savingToShare();
            createShareDialog();
            shareViewsVisible(false);  
        }

    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }

    });


    builder.show();

}

0 个答案:

没有答案