0

I want to show the URl of a video in a TOAST, each time the user click on a video. I get this toast shown only once when I Launch an app first time. Here is my Code:

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mywebview=(WebView)findViewById(R.id.webView);
    mywebview.setWebViewClient(new WebViewClient(){
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            Toast.makeText(MainActivity.this,url, Toast.LENGTH_SHORT).show();
            return true;
        }
    });
    mywebview.getSettings().setJavaScriptEnabled(true);
    mywebview.loadUrl("http://www.youtube.com");
}   
Alex K
  • 22,315
  • 19
  • 108
  • 236
  • you need to handle `OnClick` event. Otherwise you just showing the Toast at the first load, like you said. – user1908375 Jul 01 '16 at 22:42
  • see this topic: http://stackoverflow.com/a/20919146/1908375 – user1908375 Jul 01 '16 at 22:43
  • Sir in this topic stackoverflow.com/a/20919146/1908375 the onClick event is applied on javascript. but in my case I don't have a javascript file of youtube so I can i link that event with javascript – M.Zeeshan Zafar Jul 12 '16 at 18:28

0 Answers0