2017-12-24 10 views
-1

ウェブビュー内でクリックした画像のリンクを新しい意図で表示したいと考えています。クリックしたときに画像が全画面表示されないようにするサイトです。 コードのようなものが欲しいですが、ウェブサイトで同じタブに画像が表示されません。クリックした画像のリンクをウェブビューで取得する

リファレンスコード:

public class MyWebViewClient extends WebViewClient { 

@Override 
public boolean shouldOverrideUrlLoading(WebView view, String url) { 
if(url == null){ 
    return false; 
}else if (url.trim().toLowerCase().endsWith(".img")) {//use whatever image formats you are looking for here. 
    String imageUrl = url;//here is your image url, do what you want with it 
}else{ 
    view.loadUrl(url); 
} 
} 
} 
+0

は、あなたの質問にあなたのコードを共有するので、私たちは私がdosentから画像をしたいウェブサイトは、それらを開く言ったように私はこのような何かをしたいが、あなたに – Thunder

+0

を助けることができます新しいウィンドウはそれを大きくして、クリックした画像リンクが必要な理由です。 – CookieBoy

+0

はい、それはできますが、ここであなたのコードのバディを共有する必要があります – Thunder

答えて

1
public class MyWebViewClient extends WebViewClient { 

@Override 
public boolean shouldOverrideUrlLoading(WebView view, String url) { 
if(url == null){ 
return false; 
}else if (url.trim().toLowerCase().endsWith(".img")) {//use whatever 
image formats you are looking for here. 
String imageUrl = url;//here is your image url, do what you want with 
it 
Intent intent = new Intent(this, NewActivity.class); 
//pass from here the data to next activity and load there 
intent.putExtra("yourURL", imageUrl); 

startActivity(intent) 

}else{ 
view.loadUrl(url); 
} 
} 
} 
関連する問題