首页 > 解决方案 > 如何修复无法解析方法“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);

由于该错误,该应用程序无法运行,我想修复它。

标签: javaandroidandroid-fragmentsstreaming

解决方案


将您的视图添加到此行

b_play = (Button) view.findViewById(R.id.b_play);

推荐阅读