1
I have a FloatingActionButton
in the lower right corner of my screen and when it comes to the end of ListView
, it sits on top of a button. I would like to add an empty item at the end of the ListView
so that when I got to the bottom of the list that didn’t happen.
I want to do the same in Gmail:
The white space appears only when it arrives at the last item. I am using adapter for my Listview:
public class AdaptadorProdutosSemelhantes extends BaseAdapter {
String[] nomeprod,estabelecimentoprod,precoprod;
int[] imgprod;
Context context;
LayoutInflater inflater = null;
public AdaptadorProdutosSemelhantes(int[] imgprod, String[] nomeprod, String[] estabelecimentoprod, String[] precoprod, Context context) {
this.nomeprod = nomeprod;
this.estabelecimentoprod = estabelecimentoprod;
this.precoprod = precoprod;
this.context = context;
this.imgprod = imgprod;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public int getCount() {
return nomeprod.length;
}
@Override
public Object getItem(int position) {
return position;
}
@Override
public long getItemId(int position) {
return position;
}
public class Holder{
ImageView imgproduto;
TextView nomeproduto,precoproduto,estabelecimentoproduto;
Button vertodas;
RatingBar ratingBar;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
Holder h = new Holder();
View v = inflater.inflate(R.layout.lista_produtos_semelhantes,null);
h.imgproduto = (ImageView) v.findViewById(R.id.imgprodsemelhante);
h.nomeproduto = (TextView) v.findViewById(R.id.nomeprodsemelhante);
h.precoproduto= (TextView) v.findViewById(R.id.precoprodsemelhante);
h.estabelecimentoproduto = (TextView) v.findViewById(R.id.infosupprodsemelhante);
h.vertodas = (Button) v.findViewById(R.id.vertodasofertas);
h.ratingBar = (RatingBar) v.findViewById(R.id.ratingBarprodsemelhante);
h.imgproduto.setImageResource(imgprod[position]);
h.nomeproduto.setText(nomeprod[position]);
h.precoproduto.setText(precoprod[position]);
h.estabelecimentoproduto.setText(estabelecimentoprod[position]);
h.vertodas.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
}
});
return v;
}
What if you gave a padding bottom on your list? Wouldn’t solve??
– Leonardo Dias
You can add an empty item at the time you fill in your String[] in the Activity you call your Adapter. To add just check the size of your vector and add +1. You have to observe if your item has variable size. If it is variable size, you would have to set a fixed size so that the float button is not on top.
– viana