SherlockFragment中未定义的getIntent()方法

时间:2013-06-10 04:56:54

标签: java android android-intent android-fragments actionbarsherlock

出现以下错误问题

The method getIntent() is undefined for the type

使用以下extends SherlockFragment {

代码

public View onCreateView(LayoutInflater inf, ViewGroup grp, Bundle icicle) {

    View v = inf.inflate(R.layout.activity_main, grp, false);
    web = (WebView) v.findViewById(R.id.webView);
    progressBar = (ProgressBar) v.findViewById(R.id.progressBar1);
    Bundle extras = getIntent().getExtras();
    String url;
    url = extras.getString("url");
    setHasOptionsMenu(true);
    return v;

2 个答案:

答案 0 :(得分:5)

尝试使用getActivity()===> 。getActivity()getIntent()getExtras();

   Bundle extras = getActivity().getIntent().getExtras();

答案 1 :(得分:1)

尝试使用OnActivityCreated

  
    

Bundle bundle = UrFragment.this.getArguments();