私はthisの仕切りをmy gridviewに設定していますが、問題はサーバーから5つのアイテムを取得していて、gridviewに設定していますが、最後のgriditemでは灰色のボックスが表示されます。 row
番号に挿入されるもうrows
がないのでdefault
行動だこの出力https://imageshack.com/i/poKIvv1Upgridviewで仕切りを設定する方法
答えて
public class Best_Product extends BaseAdapter {
View gridView;
private Context context;
private ArrayList<HashMap<String, String>> MyArr = new ArrayList<HashMap<String, String>>();
Function_List fun_lib = new Function_List();
public Best_Product(Context c,ArrayList<HashMap<String, String>> json_value) {
// TODO Auto-generated method stub
context = c;
MyArr = json_value;
}
public int getCount() {
// TODO Auto-generated method stub
int total_size = MyArr.size();
\t \t Log.d("size of item", "" + MyArr.size());
\t \t \t if((MyArr.size()%2)==0)
\t \t \t {
\t \t \t \t // do nothing
\t \t \t }
\t \t \t else
\t \t \t {
\t \t \t \t total_size = MyArr.size()+1;
\t \t \t }
\t \t \t
return total_size;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
HashMap<String, String> mapAtPostion = MyArr.get(position);
return Long.valueOf(MyArr.get(position).get("product_id"));
}
public View getView(int position, View convertView, ViewGroup parent) {
View view = convertView;
RelativeLayout background_color; // this will be the Relativelayout of the content of GridView. you will be set backgroud color of last item
LayoutInflater inflater = (LayoutInflater) context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
\t \t \t if (view == null) {
\t \t \t \t view = new View(context);
\t \t \t \t view = inflater.inflate(R.layout.home_best_collection_content, parent, false);
\t \t \t \t background_color = (RelativeLayout)view.findViewById(R.id.bckground);
\t \t \t \t \t //checking last item of the array
\t \t \t \t if(position ==MyArr.size()-1)
\t \t \t \t {
\t \t \t \t \t //change the last item background color
\t \t \t \t \t background_color.setBackgroundColor();
\t \t \t \t }
\t \t \t \t else
\t \t \t \t {
\t \t \t \t \t \t // do the work here
\t \t \t \t }
\t \t \t }
\t \t \t else
\t \t \t {
\t \t
\t \t \t }
return view;
}
}
このコードを試してみて、私はすべての問題を教えて、 おかげ
を上書きするだけでは不可能です。これはうまくいきました。ありがとうございました。 –
素晴らしい、問題ありません、ありがとう –
を参照してください、それがbackground
「空きスペース」を示す必要があります6.もし私があなただったら、私はGridView
を取り除くた
とRecyclerView
を使用し、StaggeredLayoutManager
またはGridLayoutManager
を使用して、スパン数に対するより多くの制御を行い、それに応じて修正することができます。
はい私はそれがリサイクラーで簡単になることに同意しますが、グリッドビューではなぜですか? –
@AdityaVyasこれは一般的なGridViewの動作であり、GridViewのelemen – xAqweRx
- 1. GridViewバインドフィールドを設定する方法
- 2. listFragmentに仕切りプロパティを設定するには?
- 3. 仕切りで垂直方向のプログレスバーを作る方法
- 4. UISplitViewのiOSで仕切りの色を変更する方法
- 5. PIGでカスタム区切り文字を設定する方法
- 6. Android - 仕切り/区切り記号をボトムバーナビゲーションに追加する方法
- 7. セカイモンの設定でredisマスターを切り替える方法
- 8. 特定の仕様に出力を設定する方法
- 9. GridView EditItemTemplateテキストボックスで最大セル幅を設定する方法は?
- 10. リスナを仕切り位置に追加する方法は?
- 11. ASP.netのgridViewで1ページあたりの最大ページサイズを設定する方法
- 12. 環境設定の間に仕切線を追加するには(設定メニュー)?
- 13. GridView:表示する行の数を設定する方法
- 14. プログラムで水平方向の仕切りを追加する方法
- 15. GridViewで列を固定する方法
- 16. GridViewヘッダーフィルターを設定する
- 17. ListViewの一番上の仕切りを隠す方法は?
- 18. C++の設定を切り替える最も良い方法
- 19. GridViewにDropDownList値を設定する方法
- 20. GridViewセルのTEXTカラーを設定する方法は?
- 21. DropDownListでGridviewを設定する
- 22. NSTextViewでリッチテキストの書式設定をプログラムでココアで切り替える方法
- 23. 特定のYii2 GridView列のテキストを切り捨てて、ホバーに表示する方法はありますか?
- 24. Linux上で適切なバージョンのPHPを設定する方法
- 25. timeml仕様言語でのtid値の設定方法は?
- 26. jqueryを使用してgridviewでtextboxvalueを取得/設定する方法
- 27. SDCardを使用してgridviewで画像を設定する方法
- 28. 各アイテムのスピナー間に仕切りを設定するにはどうすればいいですか?
- 29. 特定の子供のためにgridviewアニメーションを設定する方法android
- 30. カスタムGridViewページ区切り
そして、それは何をする必要がありますしてください? – xAqweRx