java - 如何修复无法解析方法“findViewById”
问题描述
我正在使用片段构建一个广播流媒体应用程序,但我遇到了问题:
b_play = (Button) findViewById(R.id.b_play);
我试过“在‘RadioFragment’中为‘findViewById’创建方法
b_play = (Button) findViewById(R.id.b_play);
b_play.setEnabled(false);
b_play.setText("LOADING");
mediaPlayer = new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
new PlayerTask().execute(stream);
由于该错误,该应用程序无法运行,我想修复它。
解决方案
将您的视图添加到此行
b_play = (Button) view.findViewById(R.id.b_play);
推荐阅读
- vue.js - Vee Validate 3 Jest 在 Nuxt JS 中找不到用于测试的输入选择器
- android - 如何使用 numberDecimal inputType 向 EditText 添加单位?
- node.js - 使用 Node.js 将收据打印到点阵打印机
- echo - 随机数生成器去一个文件内的一个门会打开,但它说文件找不到
- math - 我该如何管理?
- django - Django 多用户类型迁移错误
- android - 使用 Company-email 在后台发送电子邮件,而不是使用 Gmail-Email
- android - 在后台线程中测量子可组合项
- encryption - 从公共哈希中获取解密密钥
- amazon-web-services - 从 Cloud SQL 迁移到可扩展的解决方案