1. Download our Official Android App: Forums for Android!

Apps How can I customize my WebView that loads a webpage

Discussion in 'Android Development' started by The7even, Jan 11, 2014.

  1. The7even

    The7even Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 18, 2013

    Nov 18, 2013
    7
    1
    6
    I'm not sure if the question is clear at all but here is what I want to do..


    I am loading a webpage using WebView.. my code looks like this..




    Code (Text):
    1. public void open() {
    2.  myWebViewV = new WebView(this);          
    3. setContentView(myWebViewV);
    4.          myWebViewV.setWebViewClient(new  WebViewClient() {
    5.  @Override            
    6. public boolean  shouldOverrideUrlLoading(WebView view, String url){
    7.                  view.loadUrl(url);
    8.                 return true;
    9.             }           });
    10.  
    11. myWebViewV.loadUrl("http://www.mywebsite.org");
    12.      }

    what this simple code does is load the website that I want to view.. fine..

    But this site also has things like "Reply", "Register", "Login" and etc..

    I'm trying to change it so that the user has to click the buttons that I create for him/her that will do basically the same thing.

    Is this possible?

    I asked on stackoverflow and only received two answers, one of them wasn't very clear.

    do I HAVE to actually know javascript too?

    I was wondering if I can just use java to do this and hoping one of the android classes handles such things.
     

    Advertisement

  2. zonk

    zonk Newbie
    Rank:
    None
    Points:
    16
    Posts:
    23
    Joined:
    Jan 10, 2014

    Jan 10, 2014
    23
    2
    16
    Male
    Your buttons can just use some kind of http method to communicate with the server, but if you want to actually interact with the webpage in your webview then yes probably need to interact with javascript...

    Building Web Apps in WebView | Android Developers
     
  3. zonk

    zonk Newbie
    Rank:
    None
    Points:
    16
    Posts:
    23
    Joined:
    Jan 10, 2014

    Jan 10, 2014
    23
    2
    16
    Male
    BTW JS is very easy if you know any other programming language ;)
     
  4. The7even

    The7even Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 18, 2013

    Nov 18, 2013
    7
    1
    6
    yeah im good with java, know it well enough i'd say.. but i really never looked at js..

    how long do you think it'd take me to learn it?
     
  5. zonk

    zonk Newbie
    Rank:
    None
    Points:
    16
    Posts:
    23
    Joined:
    Jan 10, 2014

    Jan 10, 2014
    23
    2
    16
    Male
    Honestly, minutes!

    Its very fast and loose, syntax is similar to Java / C++ / PHP etc. Variables are loose like most scripts, e.g. PHP, Lua, etc.

    Most use is just accessing the HTML / CSS DOMs

    But in reality I think (if you're writing the webpages) then you'll just use callbacks to call a Java function, so most of your stuff will be in Java as you want!
     
  6. The7even

    The7even Lurker
    Thread Starter
    Rank:
    None
    Points:
    6
    Posts:
    7
    Joined:
    Nov 18, 2013

    Nov 18, 2013
    7
    1
    6
    Thank you.

    I have no interest in really doing much with it.. but I do want to be able to add my own look to the website I'm loading in webview and want to add my own buttons and such that'll be performing the same functionality as the websites default.. didn't think i'd ever need js for that.
     
  7. zonk

    zonk Newbie
    Rank:
    None
    Points:
    16
    Posts:
    23
    Joined:
    Jan 10, 2014

    Jan 10, 2014
    23
    2
    16
    Male
    But HTML is just that, markup (formatting), you need JS to interact with it programmatically.

    lol you'll be adding lots of little features with JS soon...
     
  8. venom2124

    venom2124 Newbie
    Rank:
    None
    Points:
    36
    Posts:
    23
    Joined:
    Jan 6, 2014

    Jan 6, 2014
    23
    1
    36
    Male
    Developer
    North Carolina
    codecademy.com has a pretty good tutorial on javascript.
     

Share This Page

Loading...