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 6186613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:55:07+00:00 2026-05-24T01:55:07+00:00

I seen in android documentation where you use private class HelloWebViewClient extends WebViewClient {

  • 0

I seen in android documentation where you use

 private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {

To handle when items are clicked within a webview.

The only problem is with me, is that im setting the url in another method.

The HelloWebViewClient overrides that and doesnt use the url that the user can chose from. It just returns null..How could i over ride this method to use the url set by the user?

The URL is loaded when i use it in a regular method with the WebView browser; and then browser.loadUrl(String url)

@Override
public void onCreate(Bundle savedInstanceState){
    super.onCreate(savedInstanceState);
    setContentView(R.layout.shopping);

    findIT = (Button)findViewById(R.id.findIT);
    edittext = (EditText)findViewById(R.id.item);
    type = (RadioGroup)findViewById(R.id.console);
    site = (RadioGroup)findViewById(R.id.shopping_group);

    findIT.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            item = edittext.getText().toString();
                lookUp();
        }
    });

}

public void lookUp(){

    browser = (WebView) findViewById(R.id.shoppingBrowser);
    browser.getSettings().setJavaScriptEnabled(true);
    Log.v(item, item);
    getUserPreference();
    browser.setWebViewClient(new HelloWebViewClient());
    browser.loadUrl(url);


}



  private class HelloWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String notuse) {
        Log.v("shopping", url+" loaded");



       return true;
    }


  }
public void getUserPreference(){

    switch(type.getCheckedRadioButtonId()){
    case R.id.item:
        console = "item";
        break;
    case R.id.PS3:
        console = "item";
        break;
    case R.id.item:
        console = "item"; 
        break;

    }Log.v("item", console);
     switch(site.getCheckedRadioButtonId()){

         case R.id.store:
             url = "http://www.gamestop.com/browse?nav=16k- "+ item +"  " + console;
             break;
         case R.id.store:
             url = "http://www.google.com/search?q="+item + "   " + console+"&tbm=shop&hl=en&aq=0&oq=where+";
             break;
         case R.id.store:
             url = "http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dvideogames&field-keywords="+item + "  "+ console+"&x=0&y=0"; 
             Log.v("shopping", url);
          }
       }
  }

If you see what im trying to do the user gets to select what site they want to shop from. and from there i set it to the url.

  • 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-05-24T01:55:08+00:00Added an answer on May 24, 2026 at 1:55 am

    If the user is choosing the URL from the same activity you can just reference the URL from the member variable instead of the URL from the parameter:

    // Member variable stored to reflect user's choice
    private String mUserUrl = "http://stackoverflow.com";
    
    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // This line right here is what you're missing.
            // Use the url provided in the method.  It will match the member URL!
            view.loadUrl(url);
            return true;
        }
    }
    

    This tells the WebviewClient that you’ve overloaded the URL loading (and in fact caused it to load the URL that you wish instead of the url supplied).

    Here is a complete example of something I mocked up:

    public class HelloWebViewActivity extends Activity {
        private WebView mWebView = null;
        private EditText mInputUrl = null;
    
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        mInputUrl = (EditText)findViewById(R.id.input_url);
        Button button = (Button)findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
    
                @Override
                public void onClick(View v) {
                  String url = mInputUrl.getText().toString();
                  mWebView.loadUrl(url);
                }
            });
    
        mWebView = (WebView) findViewById(R.id.webview);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.setWebViewClient(new HelloWebViewClient());
    }
    
    private class HelloWebViewClient extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
        }
    }
    }
    

    Hope this helps. If this works for you please mark the answer as accepted.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have seen lot of threads about loading a PDF in Android Webview. But
I am trying to implement Android c2dm. I have looked into documentation and seen
I've seen plenty of samples/examples in the Android documentation about using OpenGL ES 1.x
I'm trying to use Titanium.Android.Calendar API to view the device calendar (the native one),
Seen various examples of WPF applications I've seen the use of the Grid control
While I've seen rare cases where private inheritance was needed, I've never encountered a
I would like to use Android phones as a way to do some processing
I have seen several questions regarding SocketException when using Android, but none of them
I'm new to Android programming. I've seen different phones with different screen resolutions that
I'm sure all must have seen Twitter application for android. How can i show

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.