How to open blank html page when button is pressed on android -
so i've gone through basic tutorial , i've read on activities , ui listeners.
however i'm still unsure on how open html page when select button.
what think have is, make html file , store in res/layout folder, create activity connected html file. i'm not sure do. call onclicklistener
function , when handle event of button being clicked?
you should consider starting simpler, apparent newcomer android.
be may...
first, need decide "html page" is: on phone, or on internet. right now, correct answer "on internet". need url (e.g., http://www.ohai.com/kthxbye.html
).
then, need create layout file, in res/layout/
folder, containing button
. not html file -- android layout file. assuming going run on android 1.6 , newer devices, can add attribute <button>
element, named android:onclick
, name method in soon-to-be-written activity
class. if working new project, might modify res/layout/main.xml
file supplied have button
.
then, need create activity
class. project has activity
class set you; if not, need create 1 yourself. in oncreate()
, use setcontentview(r.layout.main)
(or whatever) load layout file.
add method, of name specified in android:onclick
, activity
, returning void
, taking view
parameter. in there, add in line like:
startactivity(new intent(this, uri.parse("...")));
where ...
replaced url html file.
now, possible have html baked application, have fair bit of difficulty getting browser application view it, since application has no right application's files. there few ways deal that, of relatively complicated.
Comments
Post a Comment