好吧,我的应用程序中的计算是这样的..
有一个编辑文本框,其中来自用户的 input(number) 被解析为 int 作为nos。
根据输入,出现另外两组编辑文本框。
如果 nos 为 3,则出现来自 arrayOfEditText 的 3 个 edittext 和来自 arrayOfEditText1 的 3 个 edittext.. 并且在这些 edittext 集中输入的值用于计算。
不完整的java代码如下..
calculate.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) {
// TODO Auto-generated method stub
chk();
}
});
}
public void chk() {
EditText[] arrayOfEditText = new EditText[11];
arrayOfEditText[1] = ((EditText)findViewById(R.id.EditText01));
arrayOfEditText[2] = ((EditText)findViewById(R.id.EditText02));
arrayOfEditText[3] = ((EditText)findViewById(R.id.EditText03));
arrayOfEditText[4] = ((EditText)findViewById(R.id.EditText04));
arrayOfEditText[5] = ((EditText)findViewById(R.id.EditText05));
arrayOfEditText[6] = ((EditText)findViewById(R.id.EditText06));
arrayOfEditText[7] = ((EditText)findViewById(R.id.EditText07));
arrayOfEditText[8] = ((EditText)findViewById(R.id.EditText08));
arrayOfEditText[9] = ((EditText)findViewById(R.id.EditText09));
arrayOfEditText[10] = ((EditText)findViewById(R.id.EditText10));
EditText[] arrayOfEditText1 = new EditText[11];
arrayOfEditText1[1] = ((EditText)findViewById(R.id.EditText11));
arrayOfEditText1[2] = ((EditText)findViewById(R.id.EditText12));
arrayOfEditText1[3] = ((EditText)findViewById(R.id.EditText13));
arrayOfEditText1[4] = ((EditText)findViewById(R.id.EditText14));
arrayOfEditText1[5] = ((EditText)findViewById(R.id.EditText15));
arrayOfEditText1[6] = ((EditText)findViewById(R.id.EditText16));
arrayOfEditText1[7] = ((EditText)findViewById(R.id.EditText17));
arrayOfEditText1[8] = ((EditText)findViewById(R.id.EditText18));
arrayOfEditText1[9] = ((EditText)findViewById(R.id.EditText19));
arrayOfEditText1[10] = ((EditText)findViewById(R.id.EditText20));
for(int i=1;i<=nos;i++)
{
if(arrayOfEditText[i].getText().toString().equals("")||arrayOfEditText1[i].getText().toString().equals(""))
{
Toast.makeText(getApplicationContext(), "Dont leave points empty", 0).show();
}
else
{
calcul();
}
} } public void calcul() { EditText[] arrayOfEditText = new EditText[11];
arrayOfEditText[1] = ((EditText)findViewById(R.id.EditText01));
arrayOfEditText[2] = ((EditText)findViewById(R.id.EditText02));
arrayOfEditText[3] = ((EditText)findViewById(R.id.EditText03));
arrayOfEditText[4] = ((EditText)findViewById(R.id.EditText04));
arrayOfEditText[5] = ((EditText)findViewById(R.id.EditText05));
arrayOfEditText[6] = ((EditText)findViewById(R.id.EditText06));
arrayOfEditText[7] = ((EditText)findViewById(R.id.EditText07));
arrayOfEditText[8] = ((EditText)findViewById(R.id.EditText08));
arrayOfEditText[9] = ((EditText)findViewById(R.id.EditText09));
arrayOfEditText[10] = ((EditText)findViewById(R.id.EditText10));
EditText[] arrayOfEditText1 = new EditText[11];
arrayOfEditText1[1] = ((EditText)findViewById(R.id.EditText11));
arrayOfEditText1[2] = ((EditText)findViewById(R.id.EditText12));
arrayOfEditText1[3] = ((EditText)findViewById(R.id.EditText13));
arrayOfEditText1[4] = ((EditText)findViewById(R.id.EditText14));
arrayOfEditText1[5] = ((EditText)findViewById(R.id.EditText15));
arrayOfEditText1[6] = ((EditText)findViewById(R.id.EditText16));
arrayOfEditText1[7] = ((EditText)findViewById(R.id.EditText17));
arrayOfEditText1[8] = ((EditText)findViewById(R.id.EditText18));
arrayOfEditText1[9] = ((EditText)findViewById(R.id.EditText19));
arrayOfEditText1[10] = ((EditText)findViewById(R.id.EditText20));
for(i=1;i<=nos;i++)
{
//perform calculation
} }
现在要在//perform 计算区域执行的逻辑是..
arrayofedittext[1]*arrayofedittext1[1] + arrayofedittext[2]*arrayofedittext1[2] + arrayofedittext[3]*arrayofedittext1[3] + etc 基于nos / arrayofedittext[1] + arrayofedittext[2] + arrayofedittext[3] +等基于nos
那么有人可以帮我完成这个编码吗?:)