コード例 #1
0
  @Override
  public boolean onNavigationItemSelected(int itemPosition, long itemId) {
    if (lastPosition > -1) {
      models[lastPosition] = frag.getText();
    }
    lastPosition = itemPosition;
    frag.setText(models[itemPosition]);
    frag.setHint(labels[itemPosition]);

    return true;
  }
コード例 #2
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   if (lastPosition > -1) {
     models[lastPosition] = frag.getText();
   }
   outState.putCharSequenceArray(KEY_MODELS, models);
   outState.putInt(KEY_POSITION, getActionBar().getSelectedNavigationIndex());
 }