我正在尝试在 AlertDialog 上显示 NumberPicker。
AlertDialog 有效,但不显示 NumberPicker。
这是我的代码
public Dialog onCreateDialog(Bundle savedInstanceState){
final NumberPicker numberPicker = new NumberPicker(getActivity());
numberPicker.setMaxValue(360);
numberPicker.setMinValue(0);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("Changing the Hue");
builder.setMessage("Choose a value :");
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialogHost.onPositiveButton(numberPicker.getValue());
}
});
builder.setNegativeButton("CANCEL", new DialogInterface.OnClickListener(){
@Override
public void onClick(DialogInterface dialog, int which) {
dialogHost.onCancelButton();
}
});
return builder.create();
}
Run Code Online (Sandbox Code Playgroud) 我只是想了解管道,我正在研究一个例子:
#define _XOPEN_SOURCE 700
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
int main()
{
pid_t p;
int status;
int pipefd[2];
pipe(pipefd);
p = fork();
if(p == 0)
{
dup2(pipefd[1], 1);
close(pipefd[0]);
close(pipefd[1]);
execlp(argv[1], argv[1], NULL);
perror(argv[1]);
exit(1);
}
dup2(pipefd[0], 0);
close(pipefd[0]);
close(pipefd[1]);
execvp(argv[2], argv+2);
perror(argv[2]);
return 1;
}
Run Code Online (Sandbox Code Playgroud)
我不明白为什么这段代码在使用之前关闭了pipefd.
为什么在这里关闭?