Skip to content

Commit

Permalink
Implement mock dialog onLongPress; ready to merge
Browse files Browse the repository at this point in the history
Signed-off-by: simonewebdesign <hello@simonewebdesign.it>
  • Loading branch information
simonewebdesign committed Mar 7, 2013
1 parent 8696266 commit 4207bc9
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 29 deletions.
6 changes: 6 additions & 0 deletions src/com/example/todolist/ItemView.java
Expand Up @@ -13,11 +13,14 @@ public class ItemView extends RelativeLayout {

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);
Expand Down Expand Up @@ -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;
}
};
Expand Down
42 changes: 42 additions & 0 deletions src/com/example/todolist/ItemViewDialogFragment.java
@@ -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();
}
}
3 changes: 2 additions & 1 deletion src/com/example/todolist/MainActivity.java
Expand Up @@ -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;
Expand Down
28 changes: 0 additions & 28 deletions src/com/example/todolist/itemViewDialog.java

This file was deleted.

0 comments on commit 4207bc9

Please sign in to comment.