Changes

Jump to: navigation, search
no edit summary
}
</pre>
3.57. Run the application:<br/>
[[Image: A_main5.png | 450px]]<br/>
3.8. Add the functionality to "Search" button by implementing the <code>onClickListener()</code>:
<pre>
searchButton.setOnClickListener(new OnClickListener(){
public void onClick(View v) {
EditText contact = (EditText)findViewById(R.id.editText1);
String search = contact.getText().toString();
if(search.length() == 0){
displayData(studentList);
} else {
search = ".*" + search + ".*";
Vector<Student> studentListCopy= (Vector<Student>)studentList.clone();
for(int i = 0; i < studentListCopy.size();i++){
if (!studentListCopy.elementAt(i).getFirstname().toLowerCase().matches(search.toLowerCase()))
if(!studentListCopy.elementAt(i).getLastName().toLowerCase().matches(search.toLowerCase())) {
studentListCopy.remove(i);
}
}
displayData(studentListCopy);
}
}
});
3.9. Run the application, type in search text in the Text Field and click search button:<br/>
[[Image: A_search.png | 450px]]
</pre>
1
edit

Navigation menu