Guest User

Untitled

a guest
Apr 19th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.70 KB | None | 0 0
  1. if (mDualPane) {
  2.             // In dual-pane mode, the list view highlights the selected item.
  3.             getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
  4.             // Make sure our UI is in the correct state.
  5.             showDetails(mCurCheckPosition);
  6.         }
  7.  
  8.  
  9. void showDetails(int index) {
  10.         mCurCheckPosition = index;
  11.  
  12.         if (mDualPane) {
  13.             // We can display everything in-place with fragments, so update
  14.             // the list to highlight the selected item and show the data.
  15.             getListView().setItemChecked(index, true);
  16.  
  17.             // Check what fragment is currently shown, replace if needed.
  18.             DetailsFragment details = (DetailsFragment)
  19.                     getFragmentManager().findFragmentById(R.id.details);
  20.             if (details == null || details.getShownIndex() != index) {
  21.                 // Make new fragment to show this selection.
  22.                 details = DetailsFragment.newInstance(index);
  23.  
  24.                 // Execute a transaction, replacing any existing fragment
  25.                 // with this one inside the frame.
  26.                 FragmentTransaction ft = getFragmentManager().beginTransaction();
  27.                 ft.replace(R.id.details, details);
  28.                 ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
  29.                 ft.commit();
  30.             }
  31.  
  32.         } else {
  33.             // Otherwise we need to launch a new activity to display
  34.             // the dialog fragment with selected text.
  35.             Intent intent = new Intent();
  36.             intent.setClass(getActivity(), DetailsActivity.class);
  37.             intent.putExtra("index", index);
  38.             startActivity(intent);
  39.         }
  40.     }
Add Comment
Please, Sign In to add comment