Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TableLayout tableCreator(List<String[]> list, int noOfColumns) {
- TableLayout.LayoutParams tableParams = new TableLayout.LayoutParams(TableLayout.LayoutParams.WRAP_CONTENT, TableLayout.LayoutParams.WRAP_CONTENT);
- TableRow.LayoutParams rowParams = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT, TableRow.LayoutParams.WRAP_CONTENT, 1f);
- TableLayout tableLayout = new TableLayout(getActivity());
- tableLayout.setLayoutParams(tableParams);
- TableRow tableRow = new TableRow(getActivity());
- for (int i = 0; i < list.size(); i++) {
- View view = getView(list.get(i));
- view.setLayoutParams(rowParams);
- tableRow.addView(view);
- if (noOfColumns==1 || i % noOfColumns == 1 || i == list.size()-1) {
- tableRow.setLayoutParams(tableParams);
- tableRow.setWeightSum(1f*noOfColumns);
- tableLayout.addView(tableRow);
- tableRow = new TableRow(getActivity());
- }
- }
- return tableLayout;
- }
- public View getView(String string[]) {
- LayoutInflater inflater = getActivity().getLayoutInflater();
- View view = inflater.inflate(R.layout.panel_result_list, null);
- TextView name = (TextView) view.findViewById(R.id.name);
- TextView value = (TextView) view.findViewById(R.id.value);
- name.setText(string[0]);
- value.setText(formatDate(string[1]));
- return view;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement