我在android文档中看到你使用的地方
private class HelloWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Run Code Online (Sandbox Code Playgroud)
处理在Webview中单击项目的时间.
唯一的问题是我,是我在另一种方法中设置网址.
HelloWebViewClient会覆盖它,并且不会使用用户可以选择的URL.它只返回null ..我怎么能过度使用这个方法来使用用户设置的url?
当我与一个普通的方法使用它的URL被加载WebView browser;,然后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 …Run Code Online (Sandbox Code Playgroud) 我正在使用以下代码使用jsoup解析内容.
try{
Elements divElements = jsDoc.getElementsByTag("div");
for(Element divElement : divElements){
if(divElement.attr("class").equals("article-content")){
textList.add(divElement.text());
text = textList.toString();
}
}
}
catch(Exception e){
System.out.println("Couldnt get content");
}
Run Code Online (Sandbox Code Playgroud)
唯一的问题是内容返回括号围绕它[]那样.
我猜这是因为我正在设置它的列表.我怎样才能删除这些?
是否有适用于Android的youtube API?
如果不是,除了通过网络浏览器之外,如何从youtube获取视频呢?
任何人都可以注释掉这段代码,让我更好地了解这段代码中发生的事情吗?
谢谢.
private void putBitmapInDiskCache(Uri url, Bitmap avatar) {
File cacheDir = new File(context.getCacheDir(), "thumbnails");
File cacheFile = new File(cacheDir, ""+url.hashCode());
try {
cacheFile.createNewFile();
FileOutputStream fos = new FileOutputStream(cacheFile);
avatar.compress(CompressFormat.PNG, 100, fos);
fos.flush();
fos.close();
} catch (Exception e) {
Log.e(LOG_TAG, "Error when saving image to cache. ", e);
}
}
Run Code Online (Sandbox Code Playgroud)
阅读它们是类似的:
fis = new FileInputStream(cacheFile);
Bitmap local = BitmapFactory.decodeStream(fis);
Run Code Online (Sandbox Code Playgroud) 尝试运行此代码时,我一直收到此错误....
07-31 10:53:40.840: ERROR/AndroidRuntime(22962): Caused by: java.lang.ClassCastException: com.fttech.shoppingClass cannot be cast to android.support.v4.app.Fragment
07-31 10:53:40.840: ERROR/AndroidRuntime(22962): at android.support.v4.app.Fragment.instantiate(Fragment.java:325)
07-31 10:53:40.840: ERROR/AndroidRuntime(22962): at android.support.v4.app.Fragment.instantiate(Fragment.java:300)
Run Code Online (Sandbox Code Playgroud)
和
07-31 10:50:10.650: ERROR/AndroidRuntime(22917): Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070020 type #0x12 is not valid
07-31 10:50:10.650: ERROR/AndroidRuntime(22917): at android.content.res.Resources.loadXmlResourceParser(Resources.java:2054)
07-31 10:50:10.650: ERROR/AndroidRuntime(22917): at android.content.res.Resources.getLayout(Resources.java:853)
07-31 10:50:10.650: ERROR/AndroidRuntime(22917): at android.view.LayoutInflater.inflate(LayoutInflater.java:389)
public class shopping_details_fragment extends Fragment{
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
//Return the view for our WebView
return(inflater.inflate(R.id.shoppingWindow,container, false)); //This is where the error …Run Code Online (Sandbox Code Playgroud) 我正在从URL下载图像并将它们放入图库中.
下载图像后,它们会正确加载.
一旦从缓存加载它们,图像就会相互重叠.我该如何解决这个问题?
我正在使用此网址来检索Facebook个人资料图片.
http://graph.facebook.com/"+ Id +"/picture?=large"
Run Code Online (Sandbox Code Playgroud)
问题是,它仍然很小.它没有出现大.我如何才能显示大图像?