마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

Only the original thread that created a view hierarchy can touch its views.

0 추천

Only the original thread that created a view hierarchy can touch its views.

때문에 미치겠습니다..

 

RunOnUIThread, Post,PostDelayed,Handdler sending post msg 등을 모두 해보았지만...계속 같은 결과만 나오니 미치겠네요

 

당최 어디가 문제인건지 감을 못잡겠습니다. 간헐적으로 10번 리프레쉬 하면 3~2회 정도만 나타나니 환장하겠습니다

 

고수님들 도움이 필요합니다.

new Thread(new Runnable() {
                @Override
                public void run() {
                    try {
                        final String imageUrl = album.imageUrl;
                        final String imggesUrl = album.inAppDescription;
                         
                        URL url = new URL(imageUrl);
                        URL urls = new URL(imggesUrl);
                         
                        URLConnection conn = url.openConnection();
                        URLConnection conns = urls.openConnection();
                        InputStream is = conn.getInputStream();
                        InputStream iss = conns.getInputStream();
                    //  final Bitmap bitmap = BitmapFactory.decodeStream(is);
                        //final Bitmap bitmap1 = BitmapFactory.decodeStream(iss);
                         
                        final Bitmap bitmap;// = BitmapFactory.decodeStream(is);
                        BitmapFactory.Options options = new BitmapFactory.Options();
                        options.inSampleSize = 2;
                        bitmap = BitmapFactory.decodeStream(is, null, options);   
//                     
                        final Bitmap bitmap1;
                        BitmapFactory.Options options1 = new BitmapFactory.Options();
                        options1.inSampleSize = 2;
                        bitmap1 = BitmapFactory.decodeStream(iss, null, options1);
////                        mHandler.post(mUpdateResults);
                          
 
                        handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    bitmapCache.put(imageUrl, bitmap);
                                    bitmapCache.put(imggesUrl, bitmap1);
                                    updateImage(position, bitmap,bitmap1);
                                    progressBar.setVisibility(View.INVISIBLE);
                                }
                            });
                        } catch (Exception e) {
                            handler.post(new Runnable() {
                                @Override
                                public void run() {
                                    Bitmap bitmap = getBrokenImage();
                                    Bitmap bitmap1 = getBrokenImage();
                                    updateImage(position, bitmap,bitmap1);
                                    progressBar.setVisibility(View.INVISIBLE);
                                }
                            });
                        }
                    }
                }).start();
            }
        }
 
     
      
    
    private Bitmap getBrokenImage() {
        if (this.brokenImage != null) {
            return this.brokenImage;
        }
        Bitmap bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher);
        this.brokenImage = bitmap;
        return bitmap;
    }
 
    private void updateImage(int position, Bitmap bitmap,Bitmap bitmap1) {
        int first = listView.getFirstVisiblePosition();
        if (position < first) {
            return;
        }
        int last = listView.getLastVisiblePosition();
        if (position > last) {
            return;
        }
        AlbumView albumView = (AlbumView) listView.getChildAt(position - first);
        albumView.itemImage.setImageBitmap(bitmap);
        albumView.detailImg.setImageBitmap(bitmap1);
         
    }
     
     
private BaseAdapter adapter = new BaseAdapter() {
         
        @Override
        public int getCount() {
            return albums.size();
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            Album album = albums.get(position);
            AlbumView albumView = null;
            if (convertView != null) {
                albumView = (AlbumView)convertView;
            } else {
                albumView = new AlbumView(SettomgItemShop.this);
            }
            albumView.setAlbum(album, position);
            return albumView;
        }
         
        @Override
        public long getItemId(int position) {
            // TODO Auto-generated method stub
            return 0;
        }
         
        @Override
        public Object getItem(int position) {
            // TODO Auto-generated method stub
            return null;
        }
    };
    private String TAGS;
   

 

박하사탕2 (140 포인트) 님이 2013년 5월 26일 질문
박하사탕2님이 2013년 5월 26일 수정

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...