Reputation: 13
I have a fragment activity:
FacebookFragment.java
and
fragmnet_facebook.xml
.
In fragment_facebook.xml
, I added
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#fa6a6a"
android:orientation="vertical" >
<WebView
android:id="@+id/webView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
</RelativeLayout>
And in FacebookFragment.java
package com.appmaids.socialhub;
import com.appmaids.socialhub.R;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;
public class FacebookFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_facebook, container, false);
final WebView myWebview = (WebView)findViewById(R.id.webView1);
myWebview.loadUrl("https://www.facebook.com");
myWebview.getSettings().setJavaScriptEnabled(true);
return rootView;
}
}
I am getting an error as: The method findViewById(int) is undefined for the type FacebookFragment. I don't know what to do, someone please help! I am using eclipse.
Upvotes: 0
Views: 37
Reputation: 47817
View rootView = inflater.inflate(R.layout.fragment_facebook, container, false);
final WebView myWebview = (WebView)rootView.findViewById(R.id.webView1);
Upvotes: 1