简体   繁体   English

浮动操作按钮可见性问题?

[英]Floating action Button visibility issue?

In the below code i am trying to make fab button visible during a sip call and invisible when the call is ended.some how fab7.show doesnt show anything, only fab8.hide() works inside oncallended function.在下面的代码中,我试图让 fab 按钮在 sip 通话期间可见,而在通话结束时不可见。有些 fab7.show 不显示任何内容,只有 fab8.hide() 在 oncallended function 中工作。 Any help would be highly appreciated.任何帮助将不胜感激。

In the below code, when the Fab button was touched for more than 3 second(inside onTouchListener), i am calling sendingcall function and at the same time make fab8 visible.在下面的代码中,当 Fab 按钮被触摸超过 3 秒(在 onTouchListener 内)时,我正在调用 sendcall function 并同时使 fab8 可见。

when the call is ended, by default below function oncallend function is called, in that function i am hiding fab8.当通话结束时,默认情况下低于 function oncallend function 被调用,因为 function 我正在隐藏 fab8。

  fab.setOnTouchListener(new View.OnTouchListener() {
            @Override


            public boolean onTouch(View v, MotionEvent event) {
                call.setListener(myListener);

                switch(event.getAction()){
                    case MotionEvent.ACTION_DOWN:
                        down = System.currentTimeMillis();
                        break;
                    case MotionEvent.ACTION_UP:
                        //this is the time in milliseconds
                        re= System.currentTimeMillis();
                        differ = System.currentTimeMillis()- down;

                        if(differ>=3000){
                            sendingCall();

                            FloatingActionButton fab8 = (FloatingActionButton) findViewById(R.id.fab8);
                             fab8.show();

                        }
                        break;

                }

onCallEnded function is called everytime when the call is ended.每次通话结束时都会调用 onCallEnded function。 And here i am hiding fab button我在这里隐藏工厂按钮

  public void onCallEnded(SipAudioCall endedCall) {


       FloatingActionButton fab8 = (FloatingActionButton) findViewById(R.id.fab8);
        fab8.hide();  //***only hide works **
 FloatingActionButton fab7 = (FloatingActionButton) findViewById(R.id.fab7); fab7.show(); //. ******does not shows********
                    Log.d("call", "Call ended.................................");


}

So from what it looks like for me here you are using.setVisibility() in the onTouch event and the hide() function in the onCallEnded method.所以从我这里的样子来看,你在 onTouch 事件中使用了.setVisibility(),在 onCallEnded 方法中使用了 hide() function。 So insteadt of using.hide try using setVisibility() to hide the button again.因此,不要使用 using.hide 尝试使用 setVisibility() 再次隐藏按钮。

As suggested by @shine, i have to use only show and hide in both on touch listener as well as in oncallEnd function.正如@shine 所建议的那样,我只能在触摸监听器和 oncallEnd function 中使用显示和隐藏。 since setvisibility doesnt seems to work, most proabably depreicated as suggested.由于 setvisibility 似乎不起作用,因此很可能已按照建议弃用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM