【问题标题】:How to choose a necessary android report layout如何选择必要的android报表布局
【发布时间】:2017-04-21 17:23:39
【问题描述】:

我是安卓编程的初学者 我对为我的报告选择布局有点困惑,因为有很多布局,如 GridViewGridLayoutTableLayout 等。 由于我的基本网络,我认为制作一个像网络使用表一样的报告来显示像 datagrid 这样的数据数组

我的期望报告如下所示:

我使用GridView,但并不如预期。 感谢您的帮助。


我目前的编码和结果

public class fragment_result_listab extends Fragment {
View list_ab_result;
String selectresult_ab;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    list_ab_result= inflater.inflate(R.layout.fragment_result_listab,container,false);

    GridView gv = (GridView) list_ab_result.findViewById(R.id.listab);
     //value from other fragment (result from php)
    selectresult_ab = getArguments().getString("trans_value");


    String[] nselectresult=selectresult_ab.split(",");

    List<String> resultlist=null;


    resultlist = new ArrayList();
    for(int i = 0; i < nselectresult.length; i++) {
        resultlist.add(resultlist.size(),nselectresult[i]);

    }

    final ArrayAdapter<String> gridViewArrayAdapter = new ArrayAdapter<String>(getActivity(),R.layout.cell_gridview, resultlist);
    gv.setAdapter(gridViewArrayAdapter);


    return list_ab_result;

}

}

fragment_result_listab.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/mybg"
    android:orientation="horizontal">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="horizontal"
        tools:ignore="UselessParent">
        <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical"
            android:gravity ="center"
            android:fillViewport="true"
            android:layout_marginTop="0dp"
            android:layout_marginLeft="0dp"
            android:layout_marginRight="0dp"
            android:id="@+id/scrollViewlistab"
            tools:ignore="ObsoleteLayoutParam,UselessParent">
            <GridView
                android:id="@+id/listab"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:numColumns="4"
                tools:ignore="NestedScrolling">
            </GridView>
        </ScrollView>
    </LinearLayout>
</LinearLayout>

cell_gridview xml

<?xml version="1.0" encoding="utf-8"?>
    <TextView xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textColor="@color/mybgwhite"
        android:lines="5"
        android:maxLines="5"
       android:padding="5dp"/>

当前报告

【问题讨论】:

  • "但并不如预期。"你期待什么?你得到了什么?你用的是什么代码?没有这些,我们无法回答。 (作为记录,GridView 可能不是您所需要的,它不能满足 Web 程序员的期望。您可能需要 ListView 或 RecyclerView)
  • 代码添加了java和xml

标签: android android-layout report


【解决方案1】:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-11-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 1970-01-01
    相关资源
    最近更新 更多