Android Programming Tutorials

(Romina) #1
Now Your Friends Seem Animated

@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId()==R.id.prefs) {
startActivity(new Intent(this, EditPreferences.class));

return(true);
}
else if (item.getItemId()==R.id.location) {
insertLocation();

return(true);
}
else if (item.getItemId()==R.id.help) {
startActivity(new Intent(this, HelpPage.class));

return(true);
}
else if (item.getItemId()==R.id.status_entry) {
toggleStatusEntry();

return(true);
}

return(super.onOptionsItemSelected(item));
}

Here, we merely delegate to a toggleStatusEntry() method, so add that


method to Patchy as shown below:


private void toggleStatusEntry() {
if (status.getVisibility()==View.VISIBLE) {
status.setVisibility(View.GONE);
}
else {
status.setVisibility(View.VISIBLE);
}
}

All we do here is make the status entry row hidden (GONE) or visible


(VISIBLE), depending on its current state.


Now, when you hide the status entry row, the timeline gets more room:


267
Free download pdf