Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7821503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:40:11+00:00 2026-06-02T07:40:11+00:00

I am using the WebView of Android so that I will not have to

  • 0

I am using the WebView of Android so that I will not have to program the zoom and scroll. I have the web page that I want in the assets folder and here is my code. Each time I run in the emulator I am getting the error, no such file or directory. My question is what do I need to change in order for this to work?

Just updated my .java to this and now I receive a force close when I press button1 and my XML is the same as below.

OK I fixed that last part and now all that is happening is I get a blank screen once the app is opened.

package com.DS;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.Button;

public class CheatMathActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);


final Button button1 = (Button) findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v){

            WebView webView = (WebView) findViewById(R.id.webView);
            webView.getSettings().setJavaScriptEnabled(true);
            webView.getSettings().setBuiltInZoomControls(true);
            webView.getSettings().setSupportZoom(true);
            webView.loadUrl("file:///android_asset/stuffyoumustknowcoldforapcalc.htm");

    } });  
} 

}    

Ok Here is my XML, before the added WebView I had somewhat of a home activity that had two buttons and a textview, once I add the WebView all that the graphical layout shows is a grey screen that says WebView in the center.

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:gravity="center_horizontal"
android:orientation="vertical"
android:background="#4876ff" >
<Button
    android:id="@+id/button1"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_marginTop="90dp"
    android:textColor="#0000ff"
    android:text="AP Calculus" />
 <Button
    android:id="@+id/button2"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/button1"
    android:layout_marginTop="38dp"
    android:text="More Coming Soon!" />
<TextView
    android:id="@+id/textView1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/button2"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="87dp"
    android:textColor="#FFFAFA"
    android:text="If you have any questions or want to report a bug, feel free to email                        me at fgoyer3856@gmail.com
                    Thank you!" />
<TextView
    android:id="@+id/titleView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:layout_marginTop="37dp"
    android:gravity="center_vertical"
    android:text="Welcome to Math Cheat Sheet!"
    android:textAppearance="?android:attr/textAppearanceLarge" />
<WebView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/webView"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />
</RelativeLayout>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T07:40:12+00:00Added an answer on June 2, 2026 at 7:40 am

    Put a webview on your layout. and on your activity load your html asset like this.

    webView = (WebView) findViewById(R.id.webView1);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setBuiltInZoomControls(true);
    webView.getSettings().setSupportZoom(true);
    webView.loadUrl("file:///android_asset/stuffyoumustknowcoldforapcalc.htm");
    

    And don’t forget to put file stuffyoumustknowcoldforapcalc.htm in folder named assets.

    package com.DS;
    
    import java.io.File;
    
    import android.app.Activity;
    import android.content.Intent;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;
    import android.view.View;
    import android.widget.Button;
    import android.webkit.WebView;
    
    public class CheatMathActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
    
        final Button button1 = (Button) findViewById(R.id.button1);
        button1.setOnClickListener(new View.OnClickListener(){
            public void onClick(View v){
    
                    webView = (WebView) findViewById(R.id.webView1);
                    webView.getSettings().setJavaScriptEnabled(true);
                    webView.getSettings().setBuiltInZoomControls(true);
                    webView.getSettings().setSupportZoom(true);
                    webView.loadUrl("file:///android_asset/stuffyoumustknowcoldforapcalc.htm");
    
            } });  
        } 
    
    
    }  
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using a webview and on that web view i have a image.
I have an Android application that has one section loading a web page within
I originally started out displaying a web page in the assets folder using a
I did one sample application using WebView, in that web view the URL comes
I have an app that is displaying a webpage using a WebView control. I
I have a WebView that I'm using to open some files stored in the
I want to program an Android app -for android 2.1 and above- that does
I have an Android app using webview to load and display html pages. But
What I want to do... I have a webview in my android app. I
I have a WebView and I load a web page in to it. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.