我正在使用流动的代码,但它说该类别不存在.
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) 我的简单代码在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)
谢谢.