smartTable
smartTable copied to clipboard
请问注解模式下,怎么给column设置format
从服务器请求到数据后:
smartTable.setData(list)
val transferStatusColumn = smartTable.tableData.getColumnByFieldName("transferStatus")
transferStatusColumn.format = IFormat<String> {
when (it) {
"transfer" -> "成功汇出"
"transferPending" -> "等待汇出"
"unTransfer" -> "未汇出"
"transferRejected" -> "汇出失败"
else -> "unknown"
}
} as IFormat<Any>
我这样设置,第一次进activity的时候没问题,退出activity第二次再进就会报transferStatusColumn must not be null错
public void notifyDataChanged() {
if (tableData != null) {
config.setPaint(paint);
//开启线程
isNotifying.set(true);
new Thread(new Runnable() {
@Override
public void run() {
//long start = System.currentTimeMillis();
parser.parse(tableData);
TableInfo info = measurer.measure(tableData, config);
xAxis.setHeight(info.getTopHeight());
yAxis.setWidth(info.getyAxisWidth());
requestReMeasure();
postInvalidate();
isNotifying.set(false);
//long end = System.currentTimeMillis();
//Log.e("smartTable","notifyDataChanged timeMillis="+(end-start));
}
}).start();
}
}
发现原因了,setData()方法最终会调用notifyDataChanged(),这个方法开启线程了。。。
有什么好的解决办法吗,我现在是用Handler.postDelayed()加了500毫秒的延迟
有什么好的解决办法吗,我现在是用Handler.postDelayed()加了500毫秒的延迟
老哥搞定了吗