Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (mDualPane) {
- // In dual-pane mode, the list view highlights the selected item.
- getListView().setChoiceMode(ListView.CHOICE_MODE_SINGLE);
- // Make sure our UI is in the correct state.
- showDetails(mCurCheckPosition);
- }
- void showDetails(int index) {
- mCurCheckPosition = index;
- if (mDualPane) {
- // We can display everything in-place with fragments, so update
- // the list to highlight the selected item and show the data.
- getListView().setItemChecked(index, true);
- // Check what fragment is currently shown, replace if needed.
- DetailsFragment details = (DetailsFragment)
- getFragmentManager().findFragmentById(R.id.details);
- if (details == null || details.getShownIndex() != index) {
- // Make new fragment to show this selection.
- details = DetailsFragment.newInstance(index);
- // Execute a transaction, replacing any existing fragment
- // with this one inside the frame.
- FragmentTransaction ft = getFragmentManager().beginTransaction();
- ft.replace(R.id.details, details);
- ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
- ft.commit();
- }
- } else {
- // Otherwise we need to launch a new activity to display
- // the dialog fragment with selected text.
- Intent intent = new Intent();
- intent.setClass(getActivity(), DetailsActivity.class);
- intent.putExtra("index", index);
- startActivity(intent);
- }
- }
Add Comment
Please, Sign In to add comment