【发布时间】:2013-02-20 07:24:58
【问题描述】:
我正在扩展片段,我收到此错误消息,方法 findViewById(int) 未定义类型 Song。
findViewById 上的进度条和 webview 都会出现错误。
public class Song extends Fragment{
ProgressBar progressBar;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.song, container, false);
return myFragmentView;
progressBar = (ProgressBar)findViewById(R.id.progressBar);
final WebView mWebView = (WebView)findViewById(R.id.Browsery);
mWebView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY);
mWebView.loadUrl("....");
mWebView.setWebViewClient(new WebViewClient(){
public void onPageFinished(WebView view, String url){
progressBar.setVisibility(View.INVISIBLE);
}
});
我需要帮助
谢谢。
【问题讨论】:
-
在发布之前进行适当的编辑。
-
查看 myFragmentView = inflater.inflate(R.layout.song, container, false); progressBar = (ProgressBar)myFragmentView.findViewById(R.id.progressBar);返回我的片段视图;像这样改变你有 2 使用视图。在片段中作为其膨胀布局
标签: android android-fragments fragment android-fragmentactivity