0

再次。我创建应用程序来更改 TextSize 通过在Dialog Alert. 当我使用seekBar TextSize时将更改并显示字体编号Toast.makeText。但是Toast.makeTake不要停止增加数字,显示消息。当对话框关闭并退出应用程序时,它不会停止。我必须在设置或卸载应用程序中强制关闭应用程序。它会停止。我怎样才能解决这个问题。再次感谢。

  public void ShowDialog() {
    final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
    final SeekBar seek = new SeekBar(this);

    seek.setMax(100);

    popDialog.setIcon(R.drawable.conp);
    popDialog.setTitle(R.string.menu_settings);
    popDialog.setView(seek);

    seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        public void onProgressChanged(SeekBar seekBar, int progress,
                boolean fromUser) {

            subtitles.setTextSize(progress);

            Toast.makeText(ShowMan.this, "your textsize :" + String.valueOf(progress), Toast.LENGTH_LONG).show();
        }

        public void onStartTrackingTouch(SeekBar arg0) {
            // TODO Auto-generated method stub

        }

        public void onStopTrackingTouch(SeekBar seekBar) {
            // TODO Auto-generated method stub

        }
    });

    // Button
    popDialog.setPositiveButton("OK",
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });

    popDialog.create();
    popDialog.show();
}

&我的老师说“不要使用对话主题。

4

1 回答 1

0

在 onStopTrackingTouch() 下写那个 Toast

public void ShowDialog() {
final AlertDialog.Builder popDialog = new AlertDialog.Builder(this);
final SeekBar seek = new SeekBar(this);
int pgSeekbar;

seek.setMax(100);

popDialog.setIcon(R.drawable.conp);
popDialog.setTitle(R.string.menu_settings);
popDialog.setView(seek);

seek.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
    public void onProgressChanged(SeekBar seekBar, int progress,
            boolean fromUser) {

        subtitles.setTextSize(progress);

        pgSeekbar = progress;
    }

    public void onStartTrackingTouch(SeekBar arg0) {
        // TODO Auto-generated method stub

    }

    public void onStopTrackingTouch(SeekBar seekBar) {
        Toast.makeText(ShowMan.this, "your textsize :" + pgSeekbar, Toast.LENGTH_SHORT).show();

    }
});

// Button
popDialog.setPositiveButton("OK",
        new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
            }
        });

popDialog.create();
popDialog.show();
于 2012-12-31T08:29:43.910 回答