Android Square Picasso无法加载土耳其语字符图片网址 [英] Android Square Picasso not load Turkish character image url
本文介绍了Android Square Picasso无法加载土耳其语字符图片网址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试使用方形毕加索Web应用程序. 但是,如果我的img网址包含土耳其语字符. 毕加索无法加载img.
I try use square picasso a web Application. But if my img url contains Turkish characters. Picasso not load img.
此URL有效. http://www.bulenttiras.com/wp-content/uploads /2014/02/kokhucre.jpg
但是
此网址不起作用 http://www.bulenttiras .com/wp-content/uploads/2014/03/t%C3%BCp-bebek-tedavisi.jpg
public class CategoryAdapterClass extends BaseAdapter {
private List<CategoryHelper> categoryHelpers;
private Context context;
public CategoryAdapterClass(List<CategoryHelper> categoryHelpers, Context context) {
this.categoryHelpers = categoryHelpers;
this.context = context;
}
@Override
public int getCount() {
return categoryHelpers.size();
}
@Override
public CategoryHelper getItem(int position) {
return categoryHelpers.get( position );
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder viewHolder;
CategoryHelper categoryHelper = getItem( position );
if( convertView == null ) {
viewHolder = new ViewHolder();
convertView = LayoutInflater.from( context ).inflate(R.layout.all_categories_inflate, parent, false);
viewHolder.categoryImage = (ImageView) convertView.findViewById( R.id.categoryImage );
viewHolder.category_title = (TextView) convertView.findViewById( R.id.category_title );
viewHolder.category_excerpt = (TextView) convertView.findViewById( R.id.category_excerpt );
convertView.setTag( viewHolder );
}
else {
viewHolder = (ViewHolder) convertView.getTag();
}
String query = null;
try {
query = URLEncoder.encode(categoryHelper.getCategory_image(), "utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
viewHolder.category_title.setText( categoryHelper.getCategory_image() );
viewHolder.category_excerpt.setText( categoryHelper.getCategory_excerpt() );
Picasso.with( context ).load( query ).into( viewHolder.categoryImage );
return convertView;
}
private class ViewHolder {
ImageView categoryImage;
TextView category_title;
TextView category_excerpt;
}
}
请帮助. 对不起,英语不好. 谢谢.
Please help. Sorry bad english. Thank you.
推荐答案
我遇到了同样的问题.我唯一能找到的选择就是用编码后的字符替换所有单个土耳其语字符.
I had the same issue. The only option i could find was replacing all the single Turkish character with the encoded one.
public static String encodeTurkishCharactersInUrl(String url) {
String[] list = new String[] {"ü","ç","ı","ö","ğ","ş"," ","Ü","Ç","İ","Ö","Ğ","Ş"};
for (int i = 0; i< list.length ; i++) {
try {
url = url.replace(list[i], URLEncoder.encode(list[i],"UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return url;
}
这篇关于Android Square Picasso无法加载土耳其语字符图片网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文