-1

I'm new to android programming, is there a way to load or display the html file form asset folder in android by using View.OnClickListener

let me rephrase my question: Is it possible to write a code similar the below to call/load/display the local html file form asset folder when button is clicked

public class testing extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_testing);
        Button butt4 = (Button)findViewById(R.id.secition2);

butt4.setOnClickListener(new View.OnClickListener(){
    @Override
    public void onClick(View v) {
        String url = "http://google.com";
        Intent i = new Intent(Intent.ACTION_VIEW);
        i.setData(Uri.parse(url));
        startActivity(i)
    }
});

Do let me know if i'm not clear enough..

Many thanks in advance!!!!

Raghav
  • 1
  • 1
  • this example shows how to do it using a webview https://stackoverflow.com/questions/28549420/loading-html-file-to-webview-on-android-from-assets-folder-using-android-studio – pablobu Jul 03 '17 at 23:14

1 Answers1

0

Create a activity with webview

and pass the url in bundle extra on button click

"file:///android_asset/test.html";

get the url and load into webview

webView.loadUrl("file:///android_asset/test.html");
Jarvis
  • 1,714
  • 2
  • 20
  • 35