2013-05-27 2 views
1

데이터를 동적으로 표시하는 사용자 정의 GridView가 있습니다. 데이터가로드되었지만 스크롤이 작동하지 않는 것 같습니다. gridview를 아래로 스크롤하면 스크롤 막대가 스크롤 된 위치를 유지하지 않고 위로 이동합니다.안드로이드의 사용자 정의 GridView 스크롤 문제

다음은

public class CustomAdapter extends BaseAdapter { 

    private Context context; 
    private List<PropertiesList> myList; 

    public CustomAdapter(List<PropertiesList> paramList, Context paramContext) 
    { 
    this.myList = paramList; 
    this.context = paramContext; 
    } 

    public int getCount() 
    { 
    return this.myList.size(); 
    } 

    public Object getItem(int paramInt) 
    { 
    return Integer.valueOf(paramInt); 
    } 

    public long getItemId(int paramInt) 
    { 
    return paramInt; 
    } 

    public View getView(final int paramInt, View paramView, ViewGroup paramViewGroup) 
    { 

    View localView = View.inflate(this.context, R.layout.grid_content, null); 
    localView.setMinimumHeight((int)(0.3D * ((WindowManager)this.context.getSystemService("window")).getDefaultDisplay().getWidth())); 
    ((TextView)localView.findViewById(R.prop_type)).setText(((PropertiesList)this.myList.get(paramInt)).PropertyAddress); 

    localView.findViewById(R.id.prop_type).setBackgroundResource(color.darker_gray); 
    ((TextView)localView.findViewById(R.id.prop_price)).setText(((PropertiesList)this.myList.get(paramInt)).PropertyPrice); 
    localView.setId(paramInt); 

    ((TextView)localView.findViewById(R.id.prop_type)).setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      Toast.makeText(context, "PropertyID: "+myList.get(paramInt).PropertyID, Toast.LENGTH_SHORT).show(); 

     } 
    }); 


    return localView; 
    } 
} 

XML, 내 코드에서

<GridView 
     android:id="@+id/camera_grid" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="top|center" 
     android:columnWidth="110.0dip" 
     android:gravity="center" 
     android:horizontalSpacing="5.0dip" 
     android:numColumns="auto_fit" 
     android:orientation="vertical" 
     android:scrollingCache="false" 
     android:stretchMode="columnWidth" 
     android:verticalSpacing="5.0dip" 
     android:scrollbars="vertical" /> 

모든 잘못 구현, 사용자의 GridView 내 코드? 이 문제를 해결하는 데 나를 도와주십시오.

미리 감사드립니다.

+0

이 방법 return 문 변화가 왜 재사용하지 않았다보기 및 홀더 패턴 –

+0

@Iftikar Urrhman 칸, 왜에 대한 것입니다? uplz는이 링크를 공유 할 수 있습니까? 나는 안드로이드를 처음 사용하고 있으며이 견해와 소지자에 대해 알지 못합니다. – Mahe

답변

0
public Object getItem(int paramInt) 
    { 
    return Integer.valueOf(paramInt); 
    } 

mylist.get(paramInt);` 
+0

그게 작동하지 않았다 !! – Mahe

+0

http://www.technotalkative.com/android-gridview-example/ 안드로이드의 격자보기 용 홀더를 사용하는 방법을 보여주는이 링크를 확인하십시오. – newBie

+0

view.infate 대신 inflater.inflate를 사용하십시오. – newBie

관련 문제