Android分页工具类的实现

我们在项目开发中,经常需要频繁的使用Android分页,所以有必要实现一个封装的类来统一管理实现。

首先看下效果图:

从上图我们可以看出,这里是将listview中的数据通过底下的分页工具实现分页显示。那我们接下来先贴出代码:

第一步:实现布局,这里有两个布局文件,第一个主布局文件main.xml

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
< RelativeLayout xmlns:android = "http://schemas.android.com/apk/res/android"
android:id = "@+id/whole_region"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent"
android:orientation = "vertical" >
< HorizontalScrollView
android:id = "@+id/HorizontalScrollView01"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:layout_above = "@+id/pagebtn"
android:layout_alignParentTop = "true" >
< LinearLayout
android:layout_width = "wrap_content"
android:layout_height = "fill_parent"
android:orientation = "vertical" >
< LinearLayout
android:id = "@+id/list_view_title"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:orientation = "horizontal" >
LinearLayout >
< ListView
android:id = "@+id/list"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:fadeScrollbars = "false" >
ListView >
LinearLayout >
HorizontalScrollView >
< LinearLayout
android:id = "@id/pagebtn"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:layout_alignParentBottom = "true"
android:orientation = "vertical" >
< include layout = "@layout/pagebutton" />
LinearLayout >
RelativeLayout >

第二个布局文件pagebutton.xml.这个文件嵌套在第一个主文件中。

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
xml version = "1.0" encoding = "utf-8" ?>
< merge xmlns:android = "http://schemas.android.com/apk/res/android"
android:layout_width = "fill_parent"
android:layout_height = "fill_parent" >
< TableLayout
android:id = "@+id/TableLayout1"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:paddingLeft = "5dip"
android:paddingRight = "5dip"
android:paddingTop = "5dip"
android:shrinkColumns = "0,1,2,3,4,5,6,7"
android:stretchColumns = "0,1,2,3,4,5,6,7" >
< TableRow >
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "共"
android:textSize = "18sp" />
< TextView
android:id = "@+id/total_page_num"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:minWidth = "30dp"
android:textColor = "#C71585"
android:textSize = "18sp" />
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "页"
android:textSize = "18sp" />
< TextView
android:id = "@+id/total_record_num"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:minWidth = "60dp"
android:textColor = "#C71585"
android:textSize = "18sp" />
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "条,"
android:textSize = "18sp" />
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "每页"
android:textSize = "18sp" />
< TextView
android:id = "@+id/record_num_each_page"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:textColor = "#C71585"
android:textSize = "18sp" />
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "条"
android:textSize = "18sp" />
TableRow >
TableLayout >
< TableLayout
android:id = "@+id/TableLayout1"
android:layout_width = "fill_parent"
android:layout_height = "wrap_content"
android:paddingTop = "5dip"
android:shrinkColumns = "0,1,2,3,4,5,6,7,8"
android:stretchColumns = "0,1,2,3,4,5,6,7" >
< TableRow >
< Button
android:id = "@+id/first_page"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "|<"
android:textSize = "18sp" />
< Button
android:id = "@+id/page_up"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = " < "
android:textSize = "18sp" />
< Button
android:id = "@+id/page_down"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text=" > "
android:textSize="18sp" />
< Button
android:id = "@+id/last_page"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text=">|"
android:textSize="18sp" />
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "第"
android:textSize = "18sp" />
< EditText
android:id = "@+id/current_page"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:maxWidth = "40dip"
android:singleLine = "true"
android:textColor = "#C71585"
android:textSize = "18sp" />
< TextView
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "页"
android:textSize = "18sp" />
< Button
android:id = "@+id/to_page"
android:layout_width = "wrap_content"
android:layout_height = "wrap_content"
android:text = "转到"
android:textSize = "18sp" />
TableRow >
TableLayout >
merge >

第二步:新建一个activity,用来显示界面

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
public class BuilderList1 extends QueryContextActivity {
private PagedQueryResultHelper pagedQueryResultHelper;
private Map params;
private ListView list;
private List columnWidths;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super .onCreate(savedInstanceState);
setContentView(R.layout.mynotifylist);
setOnClickListener();
columnWidths = new ArrayList();
int weight = this .getWindowManager().getDefaultDisplay().getWidth();
columnWidths.add(weight);
pagedQueryResultHelper = new PagedQueryResultHelper( this );
pagedQueryResultHelper.setTitleCellWidth(columnWidths);
// 这个方法是用来查询数据并显示在LISTVIEW中的,我们这次的重点不在这里,我只列出不详讲,有兴趣的朋友可以自己研究下listview
// query();
}
protected void query() {
params = new HashMap();
params.put( "userName" , UserInfo.getUserName());
pagedQueryResultHelper.setQueryParams( "getBuilderList" , params,
"startNum" , "endNum" , "MyNotifyList" , R.array.build_list_name,
R.array.build_list);
if (pagedQueryResultHelper.initialQuery() == null ) {
new AlertDialog.Builder( this )
.setTitle(R.string.message_title)
.setMessage( "没有查询到相关信息,请返回!" )
.setPositiveButton(R.string.OK_text, null )
.setPositiveButton(R.string.OK_text,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog,
int which) {
BuilderList1. this .finish();
}
}).show();
}
;
list = (ListView) findViewById(R.id.list);
list.setOnItemClickListener( new OnItemClickListener() {
@Override
public void onItemClick(AdapterView adapterView, View view,
int index, long arg3) {
List> data = pagedQueryResultHelper
.getWholeResult();
Intent intent = new Intent(BuilderList1. this , FloorInfo. class );
intent.putExtra( "value" , (Serializable) data.get(index));
intent.putExtra( "buildid" , data.get(index).get( "BUILDID" )
.toString());
startActivity(intent);
}
});
}
@Override
public void onClick(View arg0) {
switch (arg0.getId()) {
case R.id.first_page:
pagedQueryResultHelper.firstPage();
break ;
case R.id.page_down:
pagedQueryResultHelper.pageDown();
break ;
case R.id.page_up:
pagedQueryResultHelper.pageUp();
break ;
case R.id.last_page:
pagedQueryResultHelper.lastPage();
break ;
case R.id.to_page:
pagedQueryResultHelper.toPage();
break ;
}
}
@Override
protected void clear() {
}
@Override
protected void setOnClickListener() {
}
}

第三步:实现这个工具类,这个类代码有些多

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
package org.Base.Utils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.Base.Activities.QueryContextActivity;
import org.Base.Container.DataTableAdapter;
import org.Base.Container.myListViewTitle;
import org.Base.Webservice.WSObjectListUtil;
import org.Base.Webservice.WSObjectMapUtil;
import org.Base.Webservice.WSObjectUtil;
import org.Base.Webservice.WSUtil;
import org.Base.Webservice.WebServiceConfig;
import org.DigitalCM.R;
import org.ksoap2.serialization.SoapObject;
import android.app.AlertDialog;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
public class PagedQueryResultHelper {
private final static int initialFromRecordNum = 1 ; // 每页从第1条开始
private final static int initialToRecordNum = 20 ; // 每页可以显示20条
public PagedQueryResultHelper(QueryContextActivity contextActivity) { // 构造函数用来初始化,主要是用来接收传过来的activity做为上下文对象
this .contextActivity = contextActivity;
findViews(); // 调用此方法找到传过来的activity的控件对象
setOnClickListener(); // 给控件设置监听
if (currentPageText != null ) { // 如果所有页面只有一页,那就只显示一页
setCurrentPage( 1 );
}
}
public List> initialQuery() {
setRecordNumEachPage(initialToRecordNum - initialFromRecordNum + 1 ); // 设置每页的记录条数
return query(initialFromRecordNum, initialToRecordNum);
}
public List> initialQuery01() {
return query(methodName, params);
}
private void setCurrentPage( int currentPage) { // 设置当前页
this .currentPage = currentPage;
currentPageText.setText(String.valueOf(currentPage));
}
public void setMarkable( boolean bMarkable) { // 这个是用来标记记录的
this .bMarkable = bMarkable;
}
public void setRecordNumEachPage( int recordNumEachPage) {); //设置每页的记录条数
this .recordNumEachPage = recordNumEachPage;
recordNumEachPageText.setText(String.valueOf(recordNumEachPage));
}
public void setTotalRecord( int totalRecord) { // 设置总记录数
this .totalRecord = totalRecord;
totalRecordNumText.setText(String.valueOf(totalRecord));
getTotalPageNumText();
}
private QueryContextActivity contextActivity;
private TextView totalPageNumText;
private TextView totalRecordNumText;
private TextView recordNumEachPageText;
private Button firstPage;
private Button pageDown;
private Button pageUp;
private Button lastPage;
private EditText currentPageText;
private Button toPage;
private int totalPage;
private int totalRecord;
private int recordNumEachPage;
private int currentPage;
private String fromRecordNumField;
private String toRecordNumField;
private String methodName;
private Map params;
private String contentTableName;
// private String countTableName;
private int headerNameId;
private int headerId;
private List columnWidths = null ;
private boolean bSetTitleValue = false ;
private List> wholeresult = null ;
private List> rows = null ;
private boolean bMarkable = false ;
private DataTableAdapter dataTableAdapter;
public void setQueryParams(String methodName, Map params,
String fromRecordNumField, String toRecordNumField,
String contentTableName, int headerNameId, int headerId) {
this .methodName = methodName;
this .params = params;
this .fromRecordNumField = fromRecordNumField;
this .toRecordNumField = toRecordNumField;
this .contentTableName = contentTableName;
// this.countTableName = countTableName;
this .headerNameId = headerNameId;
this .headerId = headerId;
}
public void setQueryParams(String methodName, Map params,
String fromRecordNumField, String toRecordNumField,
String contentTableName) {
this .methodName = methodName;
this .params = params;
this .fromRecordNumField = fromRecordNumField;
this .toRecordNumField = toRecordNumField;
this .contentTableName = contentTableName;
// this.countTableName = countTableName;
}
public void setQueryParams(String methodName, Map params,
String contentTableName, int headerNameId, int headerId) {
this .methodName = methodName;
this .params = params;
this .contentTableName = contentTableName;
this .headerNameId = headerNameId;
this .headerId = headerId;
}
public void setTitleCellWidth(List columnWidths) {
this .columnWidths = columnWidths;
}
/*
* public int getCurrentPage(){ return currentPage; }
*/
private void findViews() {
totalPageNumText = (TextView) contextActivity
.findViewById(R.id.total_page_num);
totalRecordNumText = (TextView) contextActivity
.findViewById(R.id.total_record_num);
recordNumEachPageText = (TextView) contextActivity
.findViewById(R.id.record_num_each_page);
firstPage = (Button) contextActivity.findViewById(R.id.first_page);
pageDown = (Button) contextActivity.findViewById(R.id.page_down);
pageUp = (Button) contextActivity.findViewById(R.id.page_up);
lastPage = (Button) contextActivity.findViewById(R.id.last_page);
currentPageText = (EditText) contextActivity
.findViewById(R.id.current_page);
toPage = (Button) contextActivity.findViewById(R.id.to_page);
}
private void setOnClickListener() {
if (firstPage != null ) {
firstPage.setOnClickListener(contextActivity);
}
if (pageDown != null ) {
pageDown.setOnClickListener(contextActivity);
}
if (pageUp != null ) {
pageUp.setOnClickListener(contextActivity);
}
if (lastPage != null ) {
lastPage.setOnClickListener(contextActivity);
}
if (toPage != null ) {
toPage.setOnClickListener(contextActivity);
}
}
private void getRecordNumEachPageText() {
try {
recordNumEachPage = Integer.parseInt(recordNumEachPageText
.getText().toString());
} catch (NumberFormatException e) {
Log.e( "NumberFormatException" , e.getMessage());
}
}
private boolean outOfEachPageRange() {
recordNumEachPage = Integer.parseInt(recordNumEachPageText.getText()
.toString());
if (recordNumEachPage > 20 || recordNumEachPage < 1 ) {
return true ;
}
return false ;
}
private void getTotalPageNumText() {
getRecordNumEachPageText();
if (recordNumEachPage == 0 )
return ;
if (totalRecord == 0 ) {
totalPage = 0 ;
totalPageNumText.setText(String.valueOf( 0 ));
return ;
}
if (totalRecord % recordNumEachPage == 0 ) { // java中分页常用到的计算公式
totalPage = totalRecord / recordNumEachPage;
} else {
totalPage = totalRecord / recordNumEachPage + 1 ;
}
totalPageNumText.setText(String.valueOf(totalPage));
}
public void pageDown() {
if (outOfEachPageRange()) {
AlertDialog.Builder dialog = new AlertDialog.Builder(
contextActivity);
dialog.setTitle( "提示:" ).setMessage( "每页显示条数在1~20之间!" )
.setPositiveButton( "确认" , null ).show();
return ;
}
if (currentPage != totalPage) {
setCurrentPage(++currentPage);
getTotalPageNumText();
query(recordNumEachPage * (currentPage - 1 ) + 1 , recordNumEachPage
* currentPage);
}
}
public void pageUp() {
if (outOfEachPageRange()) {
AlertDialog.Builder dialog = new AlertDialog.Builder(
contextActivity);
dialog.setTitle( "提示:" ).setMessage( "每页显示条数在1~20之间!" )
.setPositiveButton( "确认" , null ).show();
return ;
}
if (currentPage != 1 && currentPage != 0 ) {
setCurrentPage(--currentPage);
getTotalPageNumText();
query(recordNumEachPage * (currentPage - 1 ) + 1 , recordNumEachPage
* currentPage);
}
}
public void firstPage() {
if (outOfEachPageRange()) {
AlertDialog.Builder dialog = new AlertDialog.Builder(
contextActivity);
dialog.setTitle( "提示:" ).setMessage( "每页显示条数在1~20之间!" )
.setPositiveButton( "确认" , null ).show();
return ;
}
getTotalPageNumText();
if (totalPage > 1 ) {
setCurrentPage( 1 );
query( 1 , recordNumEachPage);
}
}
public void lastPage() {
if (outOfEachPageRange()) {
AlertDialog.Builder dialog = new AlertDialog.Builder(
contextActivity);
dialog.setTitle( "提示:" ).setMessage( "每页显示条数在1~20之间!" )
.setPositiveButton( "确认" , null ).show();
return ;
}
getTotalPageNumText();
if (totalPage != 1 && totalPage != 0 ) {
setCurrentPage(totalPage);
query(recordNumEachPage * (totalPage - 1 ) + 1 , totalRecord);
}
}
public void toPage() {
if (outOfEachPageRange()) {
AlertDialog.Builder dialog = new AlertDialog.Builder(
contextActivity);
dialog.setTitle( "提示:" ).setMessage( "每页显示条数在1~20之间!" )
.setPositiveButton( "确认" , null ).show();
return ;
}
try {
currentPage = Integer
.parseInt(currentPageText.getText().toString());
} catch (NumberFormatException e) {
Log.e( "NumberFormatException" , e.getMessage());
return ;
}
getTotalPageNumText();
query(recordNumEachPage * (currentPage - 1 ) + 1 , recordNumEachPage
* currentPage);
currentPageText.setText(String.valueOf(currentPage));
}
public List> query( int fromRecordNum, int toRecordNum) {
return query(methodName, params, fromRecordNumField, toRecordNumField,
fromRecordNum, toRecordNum);
}
private List> query(String methodName,
Map params, String fromRecordNumField,
String toRecordNumField, int fromRecordNum, int toRecordNum) {
params.put(fromRecordNumField, fromRecordNum);
params.put(toRecordNumField, toRecordNum);
return query(methodName, params);
}
public List> getWholeResult() {
return wholeresult;
}
public List> getResult() {
return wholeresult;
}
public List getCheckBoxState() {
return dataTableAdapter.getCheckBoxState();
}
public List> query(String methodName,
Map params) { // 此方法要重点注意,因为这里是根据webservice查询到的数据,所以要传递来方法和参数
SoapObject result = null ;
if (methodName == null ) {
if (bSetTitleValue == false ) { // 下面是实现listview的标题显示
bSetTitleValue = true ;
myListViewTitle listViewTitle = new myListViewTitle(
contextActivity);
if ( this .columnWidths != null ) {
listViewTitle.setTitleCellWidth( this .columnWidths);
}
List headerList = Arrays.asList(contextActivity
.getResources().getStringArray(headerId));
listViewTitle.setTitleCellValue(headerList);
}
return null ;
}
try {
result = WSUtil.getSoapObjectByCallingWS(
// 这里是android调用webservice的典型方法
WebServiceConfig.NAMESPACE, methodName, params,
WebServiceConfig.wsdl);
} catch (Exception e) {
new AlertDialog.Builder(contextActivity)
.setTitle(R.string.message_title)
.setMessage(R.string.connection_error)
.setPositiveButton(R.string.OK_text, null ).show();
Log.e( "Exception" , e.getMessage());
}
if (result == null ) { // 如果从webservice得到的结果为null,那我们就找到listview,并赋空值,将分页的显示值设为0
ListView list = (ListView) contextActivity.findViewById(R.id.list);
list.setAdapter( null );
setTotalRecord( 0 );
this .setCurrentPage( 0 );
return null ;
}
SoapObject dataSet = WSObjectUtil.getDataSetObject(result); // 如果从webservice得到的结果不为空,则转化成dataSet
if (dataSet == null ) { // 如果dataSet为空,则显示对话框,没有查询到相关数据
new AlertDialog.Builder(contextActivity)
.setTitle(R.string.message_title).setMessage( "没有查询到相关数据!" )
.setPositiveButton(R.string.OK_text, null );
return null ;
}
// 否则,就取得列名,并将取得的dataset转化成list型的数据,最后将数据显示在listview,并通过rows返回数据
List columnNameList = Arrays.asList(contextActivity
.getResources().getStringArray(headerNameId));
WSObjectListUtil wsObjectListUtil = new WSObjectListUtil();
if (contentTableName != null ) {
rows = wsObjectListUtil.getTableValueList(dataSet,
contentTableName, columnNameList);
} else {
rows = wsObjectListUtil.getTableValueList(dataSet, columnNameList);
}
if (wholeresult != null ) {
wholeresult.clear();
}
WSObjectMapUtil wsObjectMapUtil = new WSObjectMapUtil();
if (contentTableName != null ) {
wholeresult = wsObjectMapUtil.getRowMapList(contentTableName,
dataSet);
} else {
wholeresult = WSObjectMapUtil.getRowMapList(dataSet);
}
SoapObject countTable = (SoapObject) dataSet.getProperty(dataSet
.getPropertyCount() - 1 );
try {
totalRecord = Integer
.parseInt(countTable.getProperty( 0 ).toString());
} catch (Exception e) {
Log.e( "Exception" , e.getMessage());
}
if (totalRecord != 0 && this .totalRecord == 0
&& currentPageText != null ) {
this .setCurrentPage( 1 );
}
setTotalRecord(totalRecord);
if (bSetTitleValue == false ) {
bSetTitleValue = true ;
myListViewTitle listViewTitle = new myListViewTitle(contextActivity);
if ( this .columnWidths != null ) {
listViewTitle.setTitleCellWidth( this .columnWidths);
}
List headerList = Arrays.asList(contextActivity
.getResources().getStringArray(headerId));
listViewTitle.setTitleCellValue(headerList);
}
ListView list = (ListView) contextActivity.findViewById(R.id.list);
dataTableAdapter = new DataTableAdapter(contextActivity, rows);
if (bMarkable) {
dataTableAdapter.setMarkable( true );
}
if ( this .columnWidths != null ) {
dataTableAdapter.setColumnWidths( this .columnWidths);
}
list.setAdapter(dataTableAdapter); // 注意,关键点:将数据显示在listview
return rows; // 返回数据
}
}

你可能感兴趣的:(Android开发)