Permalink
Browse files

Implement mock dialog onLongPress; ready to merge

Signed-off-by: simonewebdesign <hello@simonewebdesign.it>
  • Loading branch information...
1 parent 8696266 commit 4207bc97609399e13417761b05c98d531b22427c @simonewebdesign committed Mar 7, 2013
@@ -13,11 +13,14 @@
private static final String TAG = "ItemView";
private ToDoRow rowEntity = null;
+ private Context context = null;
public ItemView(Context context, AttributeSet attr) {
super(context, attr);
+ this.context = context;
+
String infService = Context.LAYOUT_INFLATER_SERVICE;
LayoutInflater inflater;
inflater = (LayoutInflater) getContext().getSystemService(infService);
@@ -62,6 +65,9 @@ public boolean onLongClick(View v) {
// do something when the ItemView is longClicked
Log.v(TAG, "ItemView has been longClicked!");
+ ItemViewDialogFragment dialog = new ItemViewDialogFragment();
+ dialog.show(((MainActivity) context).getSupportFragmentManager(), "dialog");
+
return false;
}
};
@@ -0,0 +1,42 @@
+package com.example.todolist;
+
+import android.app.AlertDialog;
+import android.app.Dialog;
+import android.support.v4.app.DialogFragment;
+import android.util.Log;
+import android.content.DialogInterface;
+import android.os.Bundle;
+
+public class ItemViewDialogFragment extends DialogFragment {
+
+ private final String TAG = "ItemViewDialogFragment";
+
+ @Override
+ public Dialog onCreateDialog(Bundle savedInstanceState) {
+
+ // Use the Builder class for convenient dialog construction
+ AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
+ builder.setMessage("cancellare?")
+ .setPositiveButton("si", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ // FIRE ZE MISSILES!
+ Log.v(TAG, "IMMA FIRIN MAH LAZOR!");
+ }
+ })
+ .setNegativeButton("no", new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ // User cancelled the dialog
+ }
+ })
+ .setItems(R.array.actions_array, new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int which) {
+ // The 'which' argument contains the index position
+ // of the selected item
+ Log.v(TAG, "ITS OVER 9000!!!!!!!!!!!!!!11");
+ }
+ });
+
+ // Create the AlertDialog object and return it
+ return builder.create();
+ }
+}
@@ -13,14 +13,15 @@
import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
+import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
-public class MainActivity extends Activity {
+public class MainActivity extends FragmentActivity {
private static final String TAG = "MainActivity";
private Context context = null;
@@ -1,28 +0,0 @@
-package com.example.todolist;
-
-import android.app.AlertDialog;
-import android.app.Dialog;
-import android.app.DialogFragment;
-import android.content.DialogInterface;
-import android.os.Bundle;
-
-public class itemViewDialog extends DialogFragment{
- @Override
- public Dialog onCreateDialog(Bundle savedInstanceState) {
- // Use the Builder class for convenient dialog construction
- AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
- builder.setMessage("cancellare?")
- .setPositiveButton("si", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- // FIRE ZE MISSILES!
- }
- })
- .setNegativeButton("no", new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- // User cancelled the dialog
- }
- });
- // Create the AlertDialog object and return it
- return builder.create();
- }
-}

0 comments on commit 4207bc9

Please sign in to comment.