我下载了一个源并放入该源
使用一个GridView
我希望项目自上而下
但是顺序是从下到上
像下面的照片
我该怎么办
从上到下排列
像下面的照片
这些是我的代码
<GridView
android:layout_width="match_parent"
android:layout_height="130dp"
android:stretchMode="columnWidth"
android:numColumns="6"
android:gravity="center"
android:columnWidth="30dp"
android:layoutDirection="rtl"
android:id="@+id/grid_view_item_details_1"/>
和
public class SquaresAdapters extends BaseAdapter {
private Activity mActivity;
private List<Square> mList;
public SquaresAdapters(Activity activity, List<Square> squares) {
mActivity = activity;
mList = squares;
}
@Override
public Object getItem(int position) {
return null;
}
@Override
public int getCount() {
return mList.size();
}
@Override
public long getItemId(int position) {
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View choice;
LayoutInflater inflater = mActivity.getLayoutInflater();
if (convertView == null) {
choice = inflater.inflate(R.layout.square_view, parent, false);
TextView textChoice = (TextView) choice;
if (!mList.get(position).getState()) {
textChoice.setBackground(AppCompatResources.getDrawable(mActivity, R.drawable.background_squares_with_empty_state));
} else {
textChoice.setBackground(AppCompatResources.getDrawable(mActivity, R.drawable.background_squares_with_populated_state));
}
textChoice.setText(mList.get(position).getLetter());
if (mList.get(position).getTextColor().equals("black")) {
textChoice.setTextColor(ContextCompat.getColor(mActivity, R.color.black_dark));
} else {
textChoice.setTextColor(ContextCompat.getColor(mActivity, R.color.green16));
}
} else {
choice = convertView;
}
return choice;
}
public void setSquaresList(List<Square> list) {
mList = list;
}
}
将传递给适配器的数据反向处理,如
坦白地说,这是一个愚蠢的解决方案,但是会给您一个想法: