如何获取 EditText 的值,然后将其存储在我的数组中?
这是我的完整代码:
EditText op = (EditText)v.findViewById(R.id.operator);
array=new int [Integer.valueOf(op.getText().toString())];
for (i = 0;i<(array.length+1);i++){
LayoutInflater inflater = MainActivity.this.getLayoutInflater();
final View v2=inflater.inflate(R.layout.inputangka, null) ;
new AlertDialog.Builder(MainActivity.this)
.setIcon(R.drawable.ic_launcher)
.setTitle("number of-"+(i-1)+":")
.setView(v2)
.setNeutralButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dlg, int sumthin) {
EditText number = (EditText)v2.findViewById(R.id.number);
int number1 = Integer.valueOf(number.getText().toString());
array [i]= number1; //error line
我的错误日志:
02-05 16:33:31.374: E/AndroidRuntime(431): java.lang.ArrayIndexOutOfBoundsException
我该如何解决这个问题?