java - 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.................................");
}
解决方案
因此,从对我来说,您在 onTouch 事件中使用 .setVisibility() 并在 onCallEnded 方法中使用 hide() 函数。因此,不要使用 .hide 尝试使用 setVisibility() 再次隐藏按钮。
推荐阅读
- python - OpenCV 错误:在跟踪器对象上调用更新方法时断言失败
- angular - Angular SyntaxError:位置 0 处 JSON 中的意外标记 P
- excel - 为什么 Addon XLSX 不适用于我系统中的以下代码?
- redis - 如果我总是在 redis 中获取多个字段,那么哈希总是更可取吗?
- python - 如何以新变量的名称调用变量
- testing - 在带有内存数据库的 NestJs 的 e2e 测试中创建了多个具有相同名称的连接
- python - 按照 Django 官方教程第 2 部分,makemigrations 问题,没有得到 Add field question to choice
- android - 如何删除 android 版本 Pie 上的谷歌帐户?
- r - 在 dplyr 和 R 统计中汇总数据的变量:使用 `.data` 代词引用存储为字符串的列名:
- django - 运行 WSGI 应用程序时出错,ModuleNotFoundError: No module named 'django_countries'