小编Ess*_*PAL的帖子

Kotlin - 禁用“单位转换”功能

我仍然是 Kotlin 的相对新手,经过一番挖掘后,无法解决看起来很简单的问题。对于下面的代码,编译器返回: 对于“function = PositiveButtonClick”和 function = negativeButtonClick”,功能“单位转换”被禁用

为什么?我需要做什么?

谢谢

    called with MessageBox(context, "Hello Test", "My Message");


    fun MessageBox(contxt: Context?, title: String, message: String): Boolean {

        val builder = AlertDialog.Builder(contxt)

        with(builder) {
            setTitle(title)
            setMessage(message)
            setPositiveButton("YES", DialogInterface.OnClickListener(function = positiveButtonClick))
            setNegativeButton("NO",  DialogInterface.OnClickListener(function = negativeButtonClick))
            show()
        }

        return false
    }


    val positiveButtonClick = { dialog: DialogInterface, which: Int -> Unit
        Log.i("Dialog", "Yes")
    }

    val negativeButtonClick = { dialog: DialogInterface, which: Int -> Unit
        Log.i("Dialog", "No")
    }
Run Code Online (Sandbox Code Playgroud)

android kotlin

3
推荐指数
1
解决办法
1720
查看次数

无法写入表单的画布

我正在创建一个表格,并想在画布上画画,但我无法这样做.没有输出就没有错误.

这是简单的测试代码

procedure TForm11.Button1Click(Sender: TObject);
var
  Fm: TForm;
  R: TRect;
begin
  try
    Fm := TForm.Create(nil);
    Fm.Position := poScreenCenter;
    Fm.Caption := 'Test';
    Fm.Width := 600;
    Fm.Height := 400;
    Fm.Color := clGreen;

    Fm.Canvas.Font.Color := clBlack;
    Fm.Canvas.Font.Size := 12;
    Fm.Canvas.Pen.Color := clBlack;
    Fm.Canvas.Pen.Width := 5;
    Fm.Canvas.Brush.Color := clRed;;
    Fm.Canvas.Brush.Style := bsSolid;

    R.Left := 10;
    R.Top := 10;
    R.Width := 100;
    R.Height := 100;

    Fm.Canvas.TextOut(200, 10, 'Hello');
    Fm.Canvas.Rectangle(R);

    Fm.ShowModal;
  finally
    Fm.Free;
  end;
end;
Run Code Online (Sandbox Code Playgroud)

delphi canvas

0
推荐指数
1
解决办法
781
查看次数

标签 统计

android ×1

canvas ×1

delphi ×1

kotlin ×1