Program: 107688
Project: 107688
Buggy source:
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  inflater.inflate(R.menu.ui_message_menu,menu);
  MenuItem expendMenu=menu.findItem(R.id.ui_message_sort);
  Spinner expendItem=(Spinner)MenuItemCompat.getActionView(expendMenu);
switch (selectedType) {
case LOGCAT_MAIN:
    expendItem.setSelection(0);
  break;
case LOGCAT_SYSTEM:
expendItem.setSelection(1);
break;
case LOGCAT_EVENT:
expendItem.setSelection(2);
break;
case DMESG:
expendItem.setSelection(3);
break;
default :
break;
}
expendItem.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override public void onItemSelected(AdapterView<?> parent,View view,int position,long id){
switch (position) {
case 0:
selectedType=ipcAction.LOGCAT_MAIN;
break;
case 1:
selectedType=ipcAction.LOGCAT_SYSTEM;
break;
case 2:
selectedType=ipcAction.LOGCAT_EVENT;
break;
case 3:
selectedType=ipcAction.DMESG;
break;
}
((TextView)parent.getChildAt(0)).setTextColor(Color.WHITE);
if (stopUpdate == true) stopButton.performClick();
forceRefresh();
if (!stopUpdate) stopUpdate=false;
}
@Override public void onNothingSelected(AdapterView<?> arg0){
}
}
);
MenuItem searchMenu=menu.findItem(R.id.ui_message_search);
View searchItem=(View)MenuItemCompat.getActionView(searchMenu);
TextView searchView=(TextView)searchItem.findViewById(R.id.id_action_search_text);
searchView.setText(filterString);
searchView.addTextChangedListener(new TextWatcher(){
@Override public void onTextChanged(CharSequence cs,int arg1,int arg2,int arg3){
messageList.getFilter().filter(cs);
}
@Override public void beforeTextChanged(CharSequence arg0,int arg1,int arg2,int arg3){
}
@Override public void afterTextChanged(Editable arg0){
}
}
);
stopButton=(ImageButton)searchItem.findViewById(R.id.id_action_stop);
if (stopUpdate) stopButton.setImageResource(R.drawable.ic_action_start);
 else stopButton.setImageResource(R.drawable.ic_action_stop);
stopButton.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
stopUpdate=!stopUpdate;
if (stopUpdate) stopButton.setImageResource(R.drawable.ic_action_start);
 else stopButton.setImageResource(R.drawable.ic_action_stop);
}
}
);
ImageButton filterButton=(ImageButton)searchItem.findViewById(R.id.id_action_filter);
filterButton.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
showMultiChoiceItems();
}
}
);
super.onCreateOptionsMenu(menu,inflater);
}

Fixed version (ground truth):
@Override public void onCreateOptionsMenu(Menu menu,MenuInflater inflater){
  inflater.inflate(R.menu.ui_message_menu,menu);
  MenuItem expendMenu=menu.findItem(R.id.ui_message_sort);
  Spinner expendItem=(Spinner)MenuItemCompat.getActionView(expendMenu);
switch (selectedType) {
case LOGCAT_MAIN:
    expendItem.setSelection(0);
  break;
case LOGCAT_SYSTEM:
expendItem.setSelection(1);
break;
case LOGCAT_EVENT:
expendItem.setSelection(2);
break;
case DMESG:
expendItem.setSelection(3);
break;
default :
break;
}
expendItem.setOnItemSelectedListener(new OnItemSelectedListener(){
@Override public void onItemSelected(AdapterView<?> parent,View view,int position,long id){
switch (position) {
case 0:
selectedType=ipcAction.LOGCAT_MAIN;
break;
case 1:
selectedType=ipcAction.LOGCAT_SYSTEM;
break;
case 2:
selectedType=ipcAction.LOGCAT_EVENT;
break;
case 3:
selectedType=ipcAction.DMESG;
break;
}
if (parent.getChildAt(0) != null) ((TextView)parent.getChildAt(0)).setTextColor(Color.WHITE);
if (stopUpdate == true) stopButton.performClick();
forceRefresh();
if (!stopUpdate) stopUpdate=false;
}
@Override public void onNothingSelected(AdapterView<?> arg0){
}
}
);
MenuItem searchMenu=menu.findItem(R.id.ui_message_search);
View searchItem=(View)MenuItemCompat.getActionView(searchMenu);
TextView searchView=(TextView)searchItem.findViewById(R.id.id_action_search_text);
searchView.setText(filterString);
searchView.addTextChangedListener(new TextWatcher(){
@Override public void onTextChanged(CharSequence cs,int arg1,int arg2,int arg3){
messageList.getFilter().filter(cs);
}
@Override public void beforeTextChanged(CharSequence arg0,int arg1,int arg2,int arg3){
}
@Override public void afterTextChanged(Editable arg0){
}
}
);
stopButton=(ImageButton)searchItem.findViewById(R.id.id_action_stop);
if (stopUpdate) stopButton.setImageResource(R.drawable.ic_action_start);
 else stopButton.setImageResource(R.drawable.ic_action_stop);
stopButton.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
stopUpdate=!stopUpdate;
if (stopUpdate) stopButton.setImageResource(R.drawable.ic_action_start);
 else stopButton.setImageResource(R.drawable.ic_action_stop);
}
}
);
ImageButton filterButton=(ImageButton)searchItem.findViewById(R.id.id_action_filter);
filterButton.setOnClickListener(new OnClickListener(){
@Override public void onClick(View v){
showMultiChoiceItems();
}
}
);
super.onCreateOptionsMenu(menu,inflater);
}