آموزش های این وب سایت به صورت رایگان در دسترس است. اطلاعات بیشتر
بروز خطا
   [message]
اشتراک در سوال
رای ها
[dataList]

مشکل در لود عکس از assets

jamal2012  11 سال پیش  11 سال پیش
0 0

میخوام بین مطالبم عکس قرار بدم از دیتا بیسم میخونم همه چیز عالیه متن لود میکنه فقط وقتی میخواد عکس رو لود کنه جای خالی میاد به جای عکس کد رو هم قرار دادم کسی از دوستان میتونه کمک کنه ممنون میشم پترنم هم اینه

[image:'(.*?)'\\]
 /
 /
  public void doProcess() {
String content = G.selectedApplication.matn;

Pattern pattern = Pattern.compile("\\[image:'(.*?)'\\]");
Matcher matcher = pattern.matcher(content);
int lastIndex = 0;
while (matcher.find()) {
String newContent = content.substring(lastIndex, matcher.start(1)).replace("[image:'", "").replace("']", "");
addTextView(newContent);
String imageName = content.substring(matcher.start(1), matcher.end(1));
addImageView(imageName);
lastIndex = matcher.end(1);
}
String newContent = content.substring(lastIndex, content.length()).replace("[image:'", "").replace("']", "");
addTextView(newContent);

}


private void addImageView(String imageName) {
ImageView imageView = new ImageView(this);
Bitmap bitmap = getImageFromAssets("pictures/" + imageName);
imageView.setImageBitmap(bitmap);
layoutRoott.addView(imageView);
}


private void addTextView(String text) {
TextView textView = new TextView(this);
textView.setText(text);
textView.setTextSize(15);
textView.setTextColor(Color.RED);
layoutRoott.addView(textView);
}


private Bitmap getImageFromAssets(String imageN)
{
AssetManager assetManager = getAssets();
InputStream istr = null;
try {
istr = assetManager.open(imageN);
}
catch (IOException e) {
e.printStackTrace();
}
Bitmap bitmap = BitmapFactory.decodeStream(istr);
return bitmap;
}

}

 

 
 
 
0 0
(11 سال پیش)
 برای این سوال پاسخی وجود ندارد.

پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .