1
Well, I’m developing an app, in which if you have a navigation Drawer and in this navigation I put to open each item in a new Activity, and in each acitivty will have a layout, right so far okay. But now, I want to call a webview with Progress bar, It is already all done in the layout, but when I call by id (findViewById) in Activity presents errors, because I’m using extends Fragment and does not extend Acitivity. In this case, if I replace Fragment for Activity, it simply turns null, and the screen turns white, with no content. You can help me call this webview along with fragment?
Main activity:
//Here is the part of Activity where declares which Fragment will be the main, 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 Activity home.java, as stated earlier:
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 Activity home.java. Thank you very much!
Hello friend, I don’t know how to thank you. Thank you very, very much. You saved me from this. Thanks!
– Tech Positivo
@Techpositivo of nothing, I’m glad to have helped.
– Roney Gomes