I have a listview in my application. It works fine but when the number of elements
increases then on scrolling down and selecting any view,it shows the force close.
Why so?
The code segment is given as:
lv1 = (ListView) findViewById(R.id.listView);
lv1.setAdapter(new ArrayAdapter<String>(this,R.layout.list_item,surveyName));
// lv1 = getListView();
lv1.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
long arg3) {
ListView lv = (ListView) arg0;
TextView tv = (TextView) lv.getChildAt(arg2);
String s = tv.getText().toString();
for(int i=0;i<ss;i++){
if(surveyName[i].equals(s)){
id=surveyId[i];
}
}
Intent j=new Intent(SurveyTool.this,Survey.class);
Bundle d=new Bundle();
d.putString("surveyId", id);
d.putString("userId", userId);
j.putExtras(d);
startActivity(j);
} });