📜  如何在 android 中更改网格布局中网格的背景颜色 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:19.694000             🧑  作者: Mango

代码示例1
new ArrayAdapter(context, android.R.layout.simple_list_item_1, student_array) {
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    View view = super.getView(position, convertView, parent);

    int color = 0x00FFFFFF; // Transparent
    if (someCondition) {
      color = 0xFF0000FF; // Opaque Blue
    }

    view.setBackgroundColor(color);

    return view;
  }
};