简体   繁体   中英

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

when the call is ended, by default below function oncallend function is called, in that function i am hiding 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. 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. So insteadt of using.hide try using setVisibility() to hide the button again.

As suggested by @shine, i have to use only show and hide in both on touch listener as well as in oncallEnd function. since setvisibility doesnt seems to work, most proabably depreicated as suggested.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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