小编Apo*_*eus的帖子

在 AlertDialog 上显示 NumberPicker

我正在尝试在 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)

android android-alertdialog numberpicker

8
推荐指数
2
解决办法
6567
查看次数

什么时候和为什么我要关闭管道?

我只是想了解管道,我正在研究一个例子:

#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.

为什么在这里关闭?

c pipe

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

标签 统计

android ×1

android-alertdialog ×1

c ×1

numberpicker ×1

pipe ×1