Well, I'm developing an app, which has a navigation drawer and in this navigation I put it to open each item in a new activity, and in each acitivty will have a layout, so far so good. But now, I'm trying to call a webview with progress bar, everything is already done in the layout, but when I call them by id (findViewById) in Activity it presents errors, since I'm using extends Fragment and does not extend Acitivity. In this case, if I replace the Fragment with Activity, it simply gets null, and the screen goes white with no content. Can you help me call this Webview along with Fragment?
Main activity:
// Here is the part of the activity where it declares which fragment will be the main one, which will be the first screen:
if (id == R.id.home) {
//Aplicar fragment principal
home fragment = new home();
android.support.v4.app.FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.fragment_container, fragment);
fragmentTransaction.commit();
And here is the activity home.java, as previously stated:
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
public class home extends Fragment {
public home() {
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Chamando o layout nesta activity
return inflater.inflate(R.layout.home, container, false);
}
And here follows my home.xml layout
<ProgressBar
android:id="@+id/progressBar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<WebView
android:id="@+id/web"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/progressBar"/>
What I want is to declare the webview and progressBar in the home.java activity. Many thanks!