2013-07-11 2 views
0

0 위치에 붙어 : 내가 왜 잘 모릅니다안드로이드 어댑터는 코드입니다 내가 imageAdapter 이

import android.content.Context; 
import android.net.Uri; 
import android.util.Log; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.BaseAdapter; 
import android.widget.GridView; 
import android.widget.ImageView; 

public class ImageGalleryAdapter extends BaseAdapter { 

    private Context mContext; 

    public String[] imagePaths; 

    public ImageGalleryAdapter(Context c, String paths) { 

     mContext = c; 

     imagePaths = paths.split(";"); 

    } 

    @Override 
    public int getCount() { 
     return imagePaths.length; 
    } 

    @Override 
    public Object getItem(int position) { 
     // TODO Auto-generated method stub 

     return imagePaths[position]; 
    } 

    @Override 
    public long getItemId(int position) { 
     // TODO Auto-generated method stub 
     return 0; 
    } 

    @Override 
    public View getView(int position, View convertView, ViewGroup parent) { 
     Log.i("IMAGE GALLERY ADAPTER", ""+position); 

     ImageView imageView = new ImageView(mContext); 

     imageView.setImageURI(Uri.parse(imagePaths[position])); 


     imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); 

     imageView.setLayoutParams(new GridView.LayoutParams(70, 70)); 

     return imageView; 
    } 


} 

하지만 항상 내 응용 프로그램이 응답하지 않을 수 있도록, 그래서 내가 확인 Log.i을 설정하려고

:의 getView의 위치 결과는 위치가 imagePath.length 반면 = 4.이 항상 위치에 붙어 이유

=

이 0 로그 값 = 0 인 한 항상

07-11 18:38:25.310: I/IMAGE GALLERY ADAPTER(32154): **0** 

07-11 18:38:25.313: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg addr:0x53c64000, size:65536, fd:59 

07-11 18:38:25.316: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg reply:6 

07-11 18:38:25.316: W/skia(32154): Use JPEG SW Decoder 

07-11 18:38:25.484: I/dalvikvm-heap(32154): Grow heap (frag case) to 29.849MB for 19660816-byte allocation 

07-11 18:38:25.726: I/SurfaceTextureClient(32154): [void android::SurfaceTextureClient::init()] debug.stc.fps: 3000 ms 

07-11 18:38:25.744: E/MMUMapper(32154): fail to register MVA, unsupported format(0x5) 

07-11 18:38:25.746: I/IMAGE GALLERY ADAPTER(32154): **0** 

07-11 18:38:25.749: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg addr:0x53c64000, size:65536, fd:60 

07-11 18:38:25.751: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg reply:6 

07-11 18:38:25.751: W/skia(32154): Use JPEG SW Decoder 

07-11 18:38:25.943: I/dalvikvm-heap(32154): Grow heap (frag case) to 48.574MB for 19660816-byte allocation 

07-11 18:38:26.191: I/IMAGE GALLERY ADAPTER(32154): **0** 

07-11 18:38:26.194: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg addr:0x53c64000, size:65536, fd:60 

07-11 18:38:26.195: I/MdpService(32154): [MDP INFO](32154): BpMdpService::parseJpg reply:6 

07-11 18:38:26.195: W/skia(32154): Use JPEG SW Decoder 

07-11 18:38:26.214: I/dalvikvm-heap(32154): Forcing collection of SoftReferences for 19660816-byte allocation 

07-11 18:38:26.243: E/dalvikvm-heap(32154): Out of memory on a 19660816-byte allocation. 

메모리 exeption의 부족을 일으키는 원인이되고 추가 된 아닌 비트 맵 것처럼 것 같다이

+0

'paths'의 값은 무엇입니까? 이 값과'imagePaths '의 크기를 단계별로 기록 할 수 있습니까? –

+0

메모리 부족 오류로 인해 강제 종료되었습니다. 그것은 19 메가 바이트를 할당하려고하는 것 같습니다. – Scott

답변

2

를 해결하기 위해 도와주세요,

Out of memory on a 19660816-byte allocation. 

당신이 다시 샘플링 이미지가 작게 시도 심지어 문자열 배열에 항목을 추가?