从顶部排列GridView项

问题描述 投票:0回答:2

我下载了一个源并放入该源

使用一个GridView

我希望项目自上而下

但是顺序是从下到上

像下面的照片

enter image description here

我该怎么办

从上到下排列

像下面的照片

enter image description here

这些是我的代码

<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;
}

}

android gridview
2个回答
0
投票

将传递给适配器的数据反向处理,如


0
投票

坦白地说,这是一个愚蠢的解决方案,但是会给您一个想法:

© www.soinside.com 2019 - 2024. All rights reserved.