小编Jon*_*ock的帖子

Android 导航组件:以编程方式从与家不同的目的地开始?

我正在尝试根据github 示例实现navigation controller具有多个返回堆栈的多个BottomNavigationView。但是,该示例为每个选项卡使用了不同的导航图,这使事情变得简单。在我的情况下,我需要对所有选项卡使用相同的导航图,但起始目的地与导航图中设置的“主页目的地”不同。

到目前为止,我已经设法修改NavigationExtensions文件以实现所有选项卡的单个导航图,并且我获得了多个navControllers带有自己的后堆栈的导航图,但我无法弄清楚如何在不同的目的地启动导航图。

.navigate在获取导航控制器时尝试使用,但由于它还没有连接,所以它不起作用。关于如何实现这一目标的任何想法?谢谢你。

android android-architecture-navigation android-jetpack-navigation

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

如何使用 C# 从 PostgreSql 插入和检索图像

我正在尝试将图像插入 Postgres 并使用 C# 从 postgresql 中检索该图像。

我的表中有两列:(memberid字符不同)和member_photo(bytea)

这是我插入图像的代码:

using (FileStream pgFileStream = new FileStream("D:\\Capture.jpg", FileMode.Open, FileAccess.Read))
{
    using (BinaryReader pgReader = new BinaryReader(new BufferedStream(pgFileStream)))
    {
        NpgsqlCommand command = new NpgsqlCommand();

        byte[] ImgByteA = pgReader.ReadBytes(Convert.ToInt32(pgFileStream.Length));
        command.CommandText = "insert into membermaster (memberid, member_photo) VALUES ('65', @Image)";
        command.Connection = Program.conn;

        Program.conn.Close();
        Program.conn.Open();

        //command.Parameters.Add(new NpgsqlParameter("Image", ImgByteA));
        command.Parameters.Add("@Image", ImgByteA).Value = ImgByteA;

        command.ExecuteNonQuery();

        Program.conn.Close();
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我检索图像的代码

NpgsqlCommand command = new NpgsqlCommand();
command.CommandText = "select member_photo from membermaster where memberid='65'";
command.Connection …
Run Code Online (Sandbox Code Playgroud)

c# sql postgresql

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

调用析构函数后访问对象

在下面的代码中我~destructor()明确地调用了。但是该对象仍然可以访问。我怎样才能删除它(让它消失)?

class Queue {
    public:
    node* top = NULL;//points to the top of the queue 
    //methods:
    void enqueue(int data);//adds a node to the queue
    void dequeue();
    //printing 
    void print();
    //destructor 
    ~Queue();
};
Run Code Online (Sandbox Code Playgroud)

和析构函数:

Queue::~Queue() {
    //The destructor deletes all items from HEAP
    //Then sets the top to 0
    while (top != NULL)
        this->dequeue();//dequeue until there are NO more items
    top = 0;
}
Run Code Online (Sandbox Code Playgroud)

在源码.cpp中:

Queue q;

q.enqueue(1);
q.enqueue(2);
q.enqueue(3);
q.enqueue(4);

q.dequeue();
q.dequeue();
q.print();

q.~Queue();
q.print();//Here I need to …
Run Code Online (Sandbox Code Playgroud)

c++ oop destructor

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

立即将 unixtime 转换为 DateTime

将 unixtime 转换为 DateTime 时出现问题。

我传入参数 1663869600,这是 22 年 9 月 22 日。但在代码中,在检测后,我得到日期 1/20/1970 6:11:09 AM。

这是为什么 ?

我将通过以下方式转换日期:

DateTime start = DateTimeOffset.FromUnixTimeMilliseconds(request.StartTime).DateTime;
var startUtc = DateTime.SpecifyKind(start, DateTimeKind.Utc);
Run Code Online (Sandbox Code Playgroud)

DateTime dtDateTime = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc);
var startUtc = dtDateTime.AddMilliseconds(request.StartTime).ToLocalTime();
Run Code Online (Sandbox Code Playgroud)

c#

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