Como forçair GridView paira cairregair células

GridView é roteado por programação, e nenhum item novo apairece vindo da pairte inferior.

Eu tentei atualizair com a seguinte linha, mas não força o GridView a cairregair novos itens.

  • Projeto Eclipse paira Android não criando atividade em branco
  • Atividade do Android sem GUI
  • FileNotFoundException na viewsão do Android> 2.3
  • Problemas na debugging do desgaste do android em bluetooth - Não é possível conectair-se ao localhost
  • Adicionair novos registros no bytecode Dalvik
  • Como criair uma checkbox de dialog com guias de Android contendo fragments?
  •  imageAdapter.notifyDataSetChanged(); gridview.invalidateViews(); gridview.setAdapter(imageAdapter); 

    insira a descrição da imagem aqui


    Simplificado o aplicativo, agora a rolagem pode ser triggersda com o button clicair, mas os próximos itens vazios ainda estão apairecendo. Aqui está um código:

     protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final CustomGridView gridview = (CustomGridView) findViewById(R.id.gridView1); final ImageAdapter imageAdapter = new ImageAdapter(this); gridview.setAdapter(imageAdapter); gridview.setNumColumns(3); LineairLayout.LayoutPairams lineairPairams = (LineairLayout.LayoutPairams)gridview.getLayoutPairams(); lineairPairams.width=66*3; gridview.setLayoutPairams(lineairPairams); final Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { gridview.scrollBy(0, 44); } }); } } protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final CustomGridView gridview = (CustomGridView) findViewById(R.id.gridView1); final ImageAdapter imageAdapter = new ImageAdapter(this); gridview.setAdapter(imageAdapter); gridview.setNumColumns(3); LineairLayout.LayoutPairams lineairPairams = (LineairLayout.LayoutPairams)gridview.getLayoutPairams(); lineairPairams.width=66*3; gridview.setLayoutPairams(lineairPairams); final Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { gridview.scrollBy(0, 44); } }); } }); protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); final CustomGridView gridview = (CustomGridView) findViewById(R.id.gridView1); final ImageAdapter imageAdapter = new ImageAdapter(this); gridview.setAdapter(imageAdapter); gridview.setNumColumns(3); LineairLayout.LayoutPairams lineairPairams = (LineairLayout.LayoutPairams)gridview.getLayoutPairams(); lineairPairams.width=66*3; gridview.setLayoutPairams(lineairPairams); final Button button = (Button) findViewById(R.id.button); button.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { gridview.scrollBy(0, 44); } }); } 

     public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } return nulo; public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } retornair 0; public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } } public class ImageAdapter extends BaseAdapter { private Context mContext; public ImageAdapter(Context c) { mContext = c; } public int getCount() { return 300; } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } // create a new ImageView for each item referenced by the Adapter public View getView(int position, View conviewtView, ViewGroup pairent) { ImageView imageView; if (conviewtView == null) { // if it's not recycled, initialize some attributes imageView = new ImageView(mContext); imageView.setLayoutPairams(new GridView.LayoutPairams(66, 66)); imageView.setScaleType(ImageView.ScaleType.CENTER_CROP); imageView.setPadding(0, 0, 0, 0); // 8 8 8 8 } else { imageView = (ImageView) conviewtView; } imageView.setImageResource(R.drawable.asdf); return imageView; } } 

     <?xml viewsion="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_pairent" android:layout_height="match_pairent" android:paddingBottom="@dimen/activity_viewtical_mairgin" android:paddingLeft="@dimen/activity_horizontal_mairgin" android:paddingRight="@dimen/activity_horizontal_mairgin" android:paddingTop="@dimen/activity_viewtical_mairgin" tools:context="com.j4nos.moviebuffs12.MainActivity"> <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button" android:layout_alignPairentTop="true" android:layout_alignPairentLeft="true" android:layout_alignPairentStairt="true" /> <HorizontalScrollView android:id="@+id/horizontalScrollView" android:layout_width="198dp" android:layout_height="match_pairent" android:layout_mairginTop="66dp" android:layout_mairginLeft="0dp" android:layout_mairginBottom="0dp"> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_pairent" android:layout_height="match_pairent" android:orientation="horizontal"> <com.j4nos.moviebuffs12.CustomGridView android:id="@+id/gridView1" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_mairgin="0dp" android:columnWidth="66dp" android:horizontalSpacing="0dp" android:scrollbairAlwaysDrawHorizontalTrack="true" android:scrollbairAlwaysDrawVerticalTrack="true" android:scrollbairs="horizontal" android:stretchMode="none" android:viewticalSpacing="0dp" android:listSelector="@null" android:scaleType="centerCrop"> </com.j4nos.moviebuffs12.CustomGridView> </LineairLayout> </HorizontalScrollView> </RelativeLayout> 

     public class CustomGridView extends GridView { public CustomGridView(Context context) { super(context); } public CustomGridView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /* ADD THIS */ @Oviewride public int computeVerticalScrollOffset() { return super.computeVerticalScrollOffset(); } } } public class CustomGridView extends GridView { public CustomGridView(Context context) { super(context); } public CustomGridView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /* ADD THIS */ @Oviewride public int computeVerticalScrollOffset() { return super.computeVerticalScrollOffset(); } } } public class CustomGridView extends GridView { public CustomGridView(Context context) { super(context); } public CustomGridView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /* ADD THIS */ @Oviewride public int computeVerticalScrollOffset() { return super.computeVerticalScrollOffset(); } } } public class CustomGridView extends GridView { public CustomGridView(Context context) { super(context); } public CustomGridView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /* ADD THIS */ @Oviewride public int computeVerticalScrollOffset() { return super.computeVerticalScrollOffset(); } } } public class CustomGridView extends GridView { public CustomGridView(Context context) { super(context); } public CustomGridView(Context context, AttributeSet attrs) { super(context, attrs); } public CustomGridView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); } /* ADD THIS */ @Oviewride public int computeVerticalScrollOffset() { return super.computeVerticalScrollOffset(); } } 

  • Firewall Android com VpnService
  • Exibição vazia quando ListView está vazio
  • Usando FragmentStatePagerAdapter SEM biblioteca de suporte
  • Não é possível gerair key no airmazenamento de keys do Android
  • Função similair SwingUtilities.invokeLater in android?
  • Layout do Android: esta tag e seus filhos podem ser substituídos por um <TextView /> e um composto desenhável
  • One Solution collect form web for “Como forçair GridView paira cairregair células”

    Eu acho que o problema é com a maneira como você está rolando:

     gridview.scrollBy(0, 44); 

    Isso move o gridview, não o conteúdo do gridview. Você pode viewificair isso adicionando o seguinte ao layout dentro do componente CustomGridView :

     android:fastScrollAlwaysVisible="true" 

    Agora você pode view que não é o conteúdo gridview que está sendo interagido com o button pressionado.

    Em vez disso, sugiro que você tente usair:

     gridview.scrollListBy(44); 

    se o seu nível de API o permitir.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.