我创建了一个如下所示的共享模块。我在某处读到进口订单很重要,但我现在找不到那个链接。在某些地方它工作正常,但在其他地方我收到错误。我想知道这些模块需要的顺序以避免任何错误。
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import 'hammerjs';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { MaterialModule } from '@angular/material';
import { FlexLayoutModule } from '@angular/flex-layout';
import { CoreModule } from './core/core.module';
// NOTE: The import order matters.
const modules = [
CommonModule,
CoreModule,
ReactiveFormsModule,
FormsModule,
HttpClientModule,
MaterialModule,
FlexLayoutModule,
];
@NgModule({
imports: modules,
exports: modules
})
export class DependenciesModule { }
Run Code Online (Sandbox Code Playgroud) 编写此代码是为了按月对hashmap进行排序,但我无法完全理解.谁能解释一下呢.另外我想知道我是否正在for循环中正确访问hashmap.monthAnalysis是hashmap的名称,month是关键.对不起,我忘了提到我知道它将数据添加到表动态创建行.我的问题是前4行代码.
public void addData1(TableLayout tableLayout, HashMap<String, MonthAnalysis> monthAnalysis) {
String[] sortedMonthList = (String[]) monthAnalysis.keySet().toArray();
Arrays.sort(sortedMonthList);
for (String month : sortedMonthList) {
/* Create a TableRow dynamically */
TableRow tr = new TableRow(this);
tr.setLayoutParams(new TableLayout.LayoutParams(
TableLayout.LayoutParams.MATCH_PARENT,
TableLayout.LayoutParams.WRAP_CONTENT));
addRowItem(tr, getMonth(month), 1.3f, Typeface.DEFAULT, Color.parseColor("#000000"), Gravity.LEFT);
addRowItem(tr, Long.toString(monthAnalysis.get(month).credit), 0.9f, Typeface.DEFAULT, Color.parseColor("#000000"), Gravity.RIGHT);
addRowItem(tr, Long.toString(monthAnalysis.get(month).debit), 1f, Typeface.DEFAULT, Color.parseColor("#000000"), Gravity.RIGHT);
//addRowItem(tr, convertDate(Long.parseLong(transaction.date)), 1.5f, Typeface.DEFAULT, Color.parseColor("#000000"), Gravity.RIGHT);
tableLayout.addView(tr, new TableRow.LayoutParams(
LayoutParams.MATCH_PARENT,
LayoutParams.WRAP_CONTENT));
}
}
Run Code Online (Sandbox Code Playgroud)