小编Ash*_*sik的帖子

获取CPU使用率会生成"类别不存在"错误

我正在使用流动的代码,但它说该类别不存在.

static PerformanceCounter cpuUsage;

public static void Main(string[] args)
{
    cpuUsage = new PerformanceCounter("Processor", "% Processor Time", "_Total");

    Console.WriteLine(cpuUsage.NextValue() + " %");
    Thread.Sleep(1000);
    Console.WriteLine(cpuUsage.NextValue() + " %");
    Console.Read();
}
Run Code Online (Sandbox Code Playgroud)

c#

5
推荐指数
3
解决办法
4952
查看次数

当焦点在Android中丢失时,不要隐藏对话框

我的简单代码在Android中显示了一个Dialog.当用户在对话框外部单击或对话框失去焦点时,我不想隐藏对话框.我该怎么做?

DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
  public void onClick(DialogInterface dialog, int which) {
    switch (which) {
      case DialogInterface.BUTTON_POSITIVE:
        Toast.makeText(getApplicationContext(), "yes", Toast.LENGTH_LONG).show();
        break;
      case DialogInterface.BUTTON_NEGATIVE:
        Toast.makeText(getApplicationContext(), "no", Toast.LENGTH_LONG).show();
        break;
      }
    }
  };
Run Code Online (Sandbox Code Playgroud)

按钮代码是:

AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage("Are you sure?")
  .setPositiveButton("Yes", dialogClickListener)
  .setNegativeButton("No", dialogClickListener).show();
Run Code Online (Sandbox Code Playgroud)

谢谢.

android android-dialog

2
推荐指数
1
解决办法
4012
查看次数

标签 统计

android ×1

android-dialog ×1

c# ×1