标签: indefinite

当用户执行任何操作时如何关闭 Snackbar?

我可以像这样展示小吃店。

Snackbar snackbar = Snackbar.make(this.findViewById(android.R.id.content), "snackbar", Snackbar.LENGTH_INDEFINITE)
        .setAction("action", new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                // ...
            }
        });
snackbar.show();
Run Code Online (Sandbox Code Playgroud)

我的小吃店长度不定,我想要。但是当用户执行任何操作时,例如滚动屏幕或触摸屏幕/视图,我想关闭小吃店。我可以找到一些库和代码,但它们太复杂了。有没有简单的方法来关闭小吃店?

android indefinite dismiss snackbar

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

如何检查无限(1.#INF)和无限(1.#IND)数字?

template <class T>
MyClass
{
    public:
        // ...

        void MyMethod(T dbNumber)
        {
            // ...

            T dbResult = do_some_operation_on_dbnumber(dbNumber);

            if (IsInfinite(dbResult))
            {
                // ...
            }
            else if (IsIndefinite(dbResult))
            {
                // ...
            }
            else
            {
                // ...
            }

            // ...
        }

        static bool IsInfinite(T dbNumber)
        {
            // How do I implement this?
        }

        static bool IsIndefinite(T dbNumber)
        {
            // How do I implement this?
        }

        // ...
};
Run Code Online (Sandbox Code Playgroud)

我的代码中有一个数学运算,有时会在模板变量中返回无限且不确定的结果.我想抓住这些无限期的结果.我怎么做?

c++ templates class infinite indefinite

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

C#无限产生平台 - 会不会产生滞后?

好吧,我在C#中使用Unity工作,并且我创建了一些简单的函数来根据玩家的z位置无限地生成一系列平台(游戏对象).一旦游戏对象安全地消失,我会将其删除,并在每次玩家向前移动时调用此更新方法:

void spawnSectorGroup()
    {
        int i = numSectorsToSpawn; //get position of last sectors, when its exceeded by player then delete and spawn again
        while (i >= 0) {
            int j = Random.Range (0, sectors.Length);
            spawnSector (gamePosition.position, sectors [j]);
            i--;
        }
    }
    void checkAndUpdateSectors() 
    {
        //print ("Player pos"+playerPosition.position);
        //print ("last sector"+gamePosition.position);

        if (gamePosition.position.z - playerPosition.position.z <= 20) { //safe value ahead
            print ("theyre almost there, spawn new group");
            print (gamePosition.position.z - playerPosition.position.z);
            spawnSectorGroup ();

        }

        //destroy past ones
        GameObject[] objects = …
Run Code Online (Sandbox Code Playgroud)

c# indefinite unity-game-engine

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

C++为什么我的do-while循环在满足布尔条件时无法结束?

我当前的项目要求使用do-while循环和单独的值生成函数的程序.该程序要求输入无限量的输入,直到输入的最后两个数字之间的差值大于12.代码可以工作,但只有当它看起来很明显时.有时它会识别bool已经立即遇到并终止,有时我可以输入15个以上的数字直到它结束,如果它甚至在第一个位置结束.如果可能的话,我想保持我的代码与我目前的相似.我知道我需要一个先决条件,因为第一个输入没有什么可比较的,我正试图弄清楚这一点.

到目前为止这是我的代码:

bool TwelveApart(int x, int y);

int main()
{
    int num1, num2;
    cout << "Enter some integers: " << endl;

    do
    {
        cin >> num1 >> num2;
        TwelveApart(num1, num2);
    } while (TwelveApart(num1, num2) == false);
    cout << "The difference between " << num1 << " and " << num2 << " is greater than or equal to 12." << endl;

    return 0;
}
bool TwelveApart(int x, int y)
{
    if (abs(x - y >= 12))
    {
        return true;
    } …
Run Code Online (Sandbox Code Playgroud)

c++ boolean indefinite do-while

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