2012-12-20 5 views
0

내 listview의 마지막 행과 첫 행에 모서리가 둥글게 만들기 위해 노력하고 있습니다. 지금은 첫 번째 행에 둥근 모서리를 갖기 위해 노력하고 있습니다. 이 작업을 수행 할 수는 있지만 일반적으로 5-7 및 15 또는 16 행의 둥근 모서리 배경으로 설정된 임의의 행과 이유를 파악할 수 없습니다. 난 그냥 아무 소용로 설정하는 위치 == 0을 사용하려고했습니다첫 번째 행과 마지막 행을 사용자 정의 드로어 블로 설정하십시오.

public View getView(int position, View convertView, ViewGroup parent) { 
    View vi = convertView; 

    if (convertView == null) { 
     vi = inflater.inflate(R.layout.row, null); 
     holder = new ViewHolder(); 
     holder.title = (TextView) vi.findViewById(R.id.title); 
     holder.desc = (TextView) vi.findViewById(R.id.details); 
     holder.date = (TextView) vi.findViewById(R.id.date); 
     holder.price = (TextView) vi.findViewById(R.id.price); 
     holder.location = (TextView) vi.findViewById(R.id.location); 
     holder.newImage = (ImageView) vi.findViewById(R.id.savedNewItemsRibbon); 
     holder.rellay = (RelativeLayout) vi.findViewById(R.id.widget30); 

     //holder.image = (ImageView) vi.findViewById(R.id.thumb); 
     vi.setTag(holder); 
    }else{ 
     holder = (ViewHolder) vi.getTag(); 
    } 
    if(position == 0 && firstRow){ 
     holder.rellay.setBackgroundResource(R.drawable.roundededges); 
     firstRow = false; 
    }else{ 
     //vi.setBackgroundColor(Color.WHITE); 
    } 


    Log.d("MySQL", "COunt:"+position); 
    holder.price.setText(data.get(position).getPrice()); 
    holder.location.setText(data.get(position).getUrl()); 

    datasource = new PostDataSource(activity); 
    datasource.open(); 

    if(datasource.checkIfNew(data.get(position).getTitle())){ 
     holder.newImage.setVisibility(View.VISIBLE); 
     //vi.setBackgroundColor(Color.YELLOW); 

    }else{ 
     holder.title.setTextColor(Color.BLACK); 
    } 
    holder.title.setText(data.get(position).getTitle()); 

    holder.desc.setText(data.get(position).getDescription()); 
    holder.date.setText(data.get(position).getPubDate()); 
    holder.location.setText(data.get(position).getCity()); 


    //holder.title.setText(data.get(0).getTitle()); 
    //imageLoader.DisplayImage((data.get(position).getThumbnail()), activity,holder.image, 72, 72); 


    URL url = null; 
    try { 
     url = new URL((data.get(position).getThumbnail())); 
    } catch (MalformedURLException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 
    InputStream content = null; 


    /* 
    try { 
     //content = (InputStream)url.getContent(); 
    } catch (IOException e) { 
     // TODO Auto-generated catch block 
     e.printStackTrace(); 
    } 


    Drawable d = Drawable.createFromStream(content , "src"); 
    Bitmap mIcon1 = null; 
    try { 
     mIcon1 = 
       BitmapFactory.decodeStream(url.openConnection().getInputStream()); 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    holder.image.setImageBitmap(Bitmap.createScaledBitmap(mIcon1, 72, 72, false)); 
    */ 
    positionCount++; 
    return vi; 

} 

: 여기

내가 그릴 수 둥근 모서리를 설정하려고 내 adapter code의 일부입니다. 어떤 아이디어?

+0

. 제가 \t \t 공개 INT getCount()는 내부 @Override 의미 { 가 \t \t // TODO 자동 생성 방법은 스터브 \t \t \t} –

답변

2

프레임 워크가 첫 번째 행에서 발생하는 getView 메소드에 null이 아닌 convertView을 전달했기 때문에 가능성이 높습니다.

가장 쉬운 수정은 모든 행하지만 첫 번째의 배경 리소스 설정을 해제하는 것입니다

당신이 크기를 얻기 위해 통과하는 것을
if (position == 0){ 
     holder.rellay.setBackgroundResource(R.drawable.roundededges); 
    } else { 
     holder.rellay.setBackgroundResource(0); 
    }