【发布时间】:2020-02-26 17:24:59
【问题描述】:
在下面的代码中,我试图让 fab 按钮在 sip 通话期间可见,而在通话结束时不可见。有些 fab7.show 不显示任何内容,只有 fab8.hide() 在 oncallended 函数中起作用。任何帮助将不胜感激。
在下面的代码中,当 Fab 按钮被触摸超过 3 秒(在 onTouchListener 内) ,我正在调用 sendcall 函数,同时制作 fab8 可见。
通话结束时,默认在函数oncallend函数下面 被调用,在那个函数中我隐藏了 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 函数在每次通话结束时被调用。我在这里隐藏了 fab 按钮
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.................................");
}
【问题讨论】:
-
您可以简单地使用
fab8.setVisiblity(View.GONE)或fab8.setVisiblity(View.INVISIBLE) -
不,它们已被弃用@bhuvneshpattnaik。使用 fab8.show()
-
嗨@Shine 谢谢它解决了我的一半问题。但是 onCallEnded 函数中的一些 fab7show() 没有显示,只有隐藏部分有效。任何帮助将不胜感激
标签: java android-layout floating-action-button