I have 20 edittext,layout and autocompletetextview I want to access them and everything using arrays I am getting an error right on attaching their ids. Where am I going wrong here
LinearLayout[] laygroup ;
EditText[] etquantity,etprice ;
AutoCompleteTextView[] etproduct ;
int[] laygroupid = new int[]{R.id.laygroup0,R.id.laygroup1,R.id.laygroup2,R.id.laygroup3} ;
int[] etquantityid = new int[]{R.id.autoquantity0,R.id.autoquantity1,R.id.autoquantity2,R.id.autoquantity3};
int[] etpriceid = new int[]{R.id.autoprice0,R.id.autoprice1,R.id.autoprice2,R.id.autoprice3} ;
int[] productid = new int[] {R.id.autoproduct0,R.id.autoproduct1,R.id.autoproduct2,R.id.autoproduct3};
then in the oncreate
for(int i=0; i<=3; i++)
{
etprice[i] = (EditText)getActivity().findViewById(etpriceid[i]);
etquantity[i] = (EditText)getActivity().findViewById(etquantityid[i]);
laygroup[i] = (LinearLayout)getActivity().findViewById(laygroupid[i]) ;
etproduct[i] = (AutoCompleteTextView)getActivity().findViewById(productid[i]);
}
Try this..
You have to initialize the size arrays.
LinearLayout[] laygroup = new LinearLayout[3];
EditText[] etquantity = new EditText[3];
EditText[] etprice = new EditText[3];
AutoCompleteTextView[] = new etproduct EditText[3];