我试图创建一个textviews
变量数组,如下所示,但是eclipse用红色波浪线强调了存储在数组中的textview
变量。我不知道为什么?
Java_code:
int [] viewsRefsIds = {R.id.reportLocNameValue, R.id.reportLocLatValue, R.id.reportLocLngValue, R.id.reportTimeValue,
R.id.reportDateValue, R.id.reportImgTitleValue, R.id.reportImgPathValue
};
TextView [] viewsVariables = {reportAlertDialogLocName, reportAlertDialogLocLat, reportAlertDialogLocLng,
reportAlertDialogTime, reportAlertDialogDate, reportAlertDialogImgTitle, reportAlertDialogImgPath
};
TextView reportAlertDialogMSG = (TextView) reportAlertDialog.findViewById(R.id.reportDialogMessageID);
reportAlertDialogMSG.setText(REPORT_ALERT_DIALOG_MSG);
for (int i=0; i<bundleVals.length; i++) {
viewsVariables[i] = (TextView) reportAlertDialog.findViewById(viewsRefsIds[i]);
}
答案 0 :(得分:0)
对我而言,这是有效的......
int[] viewsRefsIds = {R.id.text,...};
TextView[] viewsVariables = new TextView[viewsRefsIds.length];
for (int i=0; i<viewsRefsIds.length; i++) {
viewsVariables[i] = (TextView)findViewById(viewsRefsIds[i]);
}
也许是&#34;清洁&#34;帮助:)