summaryrefslogtreecommitdiff
path: root/samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java
diff options
context:
space:
mode:
Diffstat (limited to 'samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java')
-rw-r--r--samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java109
1 files changed, 0 insertions, 109 deletions
diff --git a/samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java b/samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java
deleted file mode 100644
index 6c6abef..0000000
--- a/samples/fragments/src/com/actionbarsherlock/sample/fragments/FragmentAlertDialogSupport.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.actionbarsherlock.sample.fragments;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.content.DialogInterface;
-import android.os.Bundle;
-import android.support.v4.app.DialogFragment;
-import android.util.Log;
-import android.view.View;
-import android.view.View.OnClickListener;
-import android.widget.Button;
-import android.widget.TextView;
-import com.actionbarsherlock.app.SherlockDialogFragment;
-import com.actionbarsherlock.app.SherlockFragmentActivity;
-
-/**
- * Demonstrates how to show an AlertDialog that is managed by a Fragment.
- */
-public class FragmentAlertDialogSupport extends SherlockFragmentActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- setTheme(SampleList.THEME); //Used for theme switching in samples
- super.onCreate(savedInstanceState);
- setContentView(R.layout.fragment_dialog);
-
- View tv = findViewById(R.id.text);
- ((TextView)tv).setText("Example of displaying an alert dialog with a DialogFragment");
-
- // Watch for button clicks.
- Button button = (Button)findViewById(R.id.show);
- button.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- showDialog();
- }
- });
- }
-
-
- void showDialog() {
- DialogFragment newFragment = MyAlertDialogFragment.newInstance(
- R.string.alert_dialog_two_buttons_title);
- newFragment.show(getSupportFragmentManager(), "dialog");
- }
-
- public void doPositiveClick() {
- // Do stuff here.
- Log.i("FragmentAlertDialog", "Positive click!");
- }
-
- public void doNegativeClick() {
- // Do stuff here.
- Log.i("FragmentAlertDialog", "Negative click!");
- }
-
-
-
- public static class MyAlertDialogFragment extends SherlockDialogFragment {
-
- public static MyAlertDialogFragment newInstance(int title) {
- MyAlertDialogFragment frag = new MyAlertDialogFragment();
- Bundle args = new Bundle();
- args.putInt("title", title);
- frag.setArguments(args);
- return frag;
- }
-
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- int title = getArguments().getInt("title");
-
- return new AlertDialog.Builder(getActivity())
- .setIcon(R.drawable.alert_dialog_icon)
- .setTitle(title)
- .setPositiveButton(R.string.alert_dialog_ok,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- ((FragmentAlertDialogSupport)getActivity()).doPositiveClick();
- }
- }
- )
- .setNegativeButton(R.string.alert_dialog_cancel,
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {
- ((FragmentAlertDialogSupport)getActivity()).doNegativeClick();
- }
- }
- )
- .create();
- }
- }
-
-}