My app dynamically inflates some XML and adds it to an already existing layout that is nested in a scroll view. In each of the layouts that is inflated, I have an EditText that I need to get the text of later. I get a NullPointerException because it cannot find the editText. Anyways, this is my loop that grabs the text of the EditTexts:
BTW the +1000 is so it doesnt interfere with Items that were set using .setId()
for(i=1;i<numOfItems;i++){
etIndex = (EditText)findViewById(numOfItems+1000);
listOptions.add(etIndex.getText().toString());
}
It is returning a NullPointerException because the etIndex is empty when I try to get the text.
Here is the code where I inflate the EditText:
etItem = (EditText)newView.findViewById(R.id.etItem);
etItem.setId(numOfItems+1000);
etItem.setHint("List Item " + numOfItems);