Search in sources :

Example 6 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project NoteText by ViWu.

the class MainActivity method setupListViewListener.

// Attaches a long click listener and click listener to the listview
private void setupListViewListener() {
    lvItems.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> adapter, View item, int pos, long id) {
            // Remove the item within array at position
            position = pos;
            new AlertDialog.Builder(MainActivity.this).setTitle("Delete entry").setMessage("Are you sure you want to delete this entry?").setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                    //continue with delete
                    questions.remove(getPos());
                    answers.remove(getPos());
                    //Refresh the adapter
                    itemsAdapter.notifyDataSetChanged();
                    checkNoQuestionsExists();
                }
            }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int which) {
                // do nothing
                }
            }).setIcon(android.R.drawable.ic_dialog_alert).show();
            // Return true consumes the long click event (marks it handled)
            return true;
        }
    });
    final Intent[] intent = { null };
    lvItems.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            intent[0] = new Intent(MainActivity.this, EditCard.class);
            intent[0].putExtra("questions", questions.get(position));
            intent[0].putExtra("answers", answers.get(position));
            intent[0].putExtra("position", position);
            intent[0].putExtra("setName", setName);
            startActivity(intent[0]);
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) AdapterView(android.widget.AdapterView)

Example 7 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project UltimateAndroid by cymcsg.

the class DraggableGridViewPagerTestActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.draggable_grid_view_pager_test);
    mDraggableGridViewPager = (DraggableGridViewPager) findViewById(R.id.draggable_grid_view_pager);
    mAddButton = (Button) findViewById(R.id.add);
    mRemoveButton = (Button) findViewById(R.id.remove);
    mAdapter = new ArrayAdapter<String>(this, 0) {

        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
            final String text = getItem(position);
            if (convertView == null) {
                convertView = (TextView) getLayoutInflater().inflate(R.layout.draggable_grid_item, null);
            }
            ((TextView) convertView).setText(text);
            return convertView;
        }
    };
    mDraggableGridViewPager.setAdapter(mAdapter);
    mDraggableGridViewPager.setOnPageChangeListener(new DraggableGridViewPager.OnPageChangeListener() {

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
            Log.v(TAG, "onPageScrolled position=" + position + ", positionOffset=" + positionOffset + ", positionOffsetPixels=" + positionOffsetPixels);
        }

        @Override
        public void onPageSelected(int position) {
            Log.i(TAG, "onPageSelected position=" + position);
        }

        @Override
        public void onPageScrollStateChanged(int state) {
            Log.d(TAG, "onPageScrollStateChanged state=" + state);
        }
    });
    mDraggableGridViewPager.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            showToast(((TextView) view).getText().toString());
        }
    });
    mDraggableGridViewPager.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            showToast(((TextView) view).getText().toString() + " long clicked!!!");
            return true;
        }
    });
    mDraggableGridViewPager.setOnRearrangeListener(new DraggableGridViewPager.OnRearrangeListener() {

        @Override
        public void onRearrange(int oldIndex, int newIndex) {
            Log.i(TAG, "OnRearrangeListener.onRearrange from=" + oldIndex + ", to=" + newIndex);
            String item = mAdapter.getItem(oldIndex);
            mAdapter.setNotifyOnChange(false);
            mAdapter.remove(item);
            mAdapter.insert(item, newIndex);
            mAdapter.notifyDataSetChanged();
        }
    });
    mAddButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            mGridCount++;
            mAdapter.add("Grid" + mGridCount);
        }
    });
    mRemoveButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            if (mAdapter.getCount() > 0) {
                mAdapter.remove(mAdapter.getItem(mAdapter.getCount() - 1));
            }
        }
    });
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) ViewGroup(android.view.ViewGroup) TextView(android.widget.TextView) View(android.view.View) AdapterView(android.widget.AdapterView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) DraggableGridViewPager(com.marshalchen.common.ui.DraggableGridViewPager) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView)

Example 8 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project Fairphone by Kwamecorp.

the class EditFavoritesActivity method setupAllAppsList.

/**
	 * Setup the list with all the apps installed on the device.
	 */
private void setupAllAppsList() {
    mAllAppsGridView = (EditFavoritesGridView) findViewById(R.id.allAppsGridView);
    mAllAppsListAdapter = new AllAppsListAdapter(this);
    mAllAppsListAdapter.setAllApps(mAllApps);
    mAllAppsGridView.setLongClickable(true);
    mAllAppsGridView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View v, int position, long id) {
            startDraggingIcon(v, position);
            return true;
        }
    });
    mAllAppsGridView.setOnEditFavouritesIconDraggedListener(new OnEditFavouritesIconDraggedListener() {

        @Override
        public void OnEditFavouritesIconDragged(AdapterView<?> parent, View view, int position, long id) {
            startDraggingIcon(view, position);
        }
    });
    mAllAppsGridView.setAdapter(mAllAppsListAdapter);
    // set the drag listener to enable favorite icon removal
    View allAppsGroupView = findViewById(R.id.allAppsGroup);
    allAppsGroupView.setOnDragListener(new DropDragEventListener(this, mFavIcons, mSelectedApps, mAllApps, true));
}
Also used : OnEditFavouritesIconDraggedListener(org.fairphone.launcher.edgeswipe.ui.EditFavoritesGridView.OnEditFavouritesIconDraggedListener) EditFavoritesGridView(org.fairphone.launcher.edgeswipe.ui.EditFavoritesGridView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Point(android.graphics.Point)

Example 9 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project RoboBinding-gallery by RoboBinding.

the class ContextualActionModeActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MemoryProductStore productStore = MemoryProductStore.getInstance();
    productStore.reset();
    presentationModel = new ContextualActionModePresentationModel(productStore);
    initializeContentView(R.layout.activity_contextual_action_mode, presentationModel);
    ListView productListView = (ListView) findViewById(R.id.productList);
    productListView.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
            startSupportActionMode(new ActionMode.Callback() {

                @Override
                public boolean onPrepareActionMode(ActionMode actionMode, Menu menu) {
                    return false;
                }

                @Override
                public void onDestroyActionMode(ActionMode actionMode) {
                }

                @Override
                public boolean onCreateActionMode(ActionMode actionMode, Menu menu) {
                    MenuBinder menuBinder = createMenuBinder(menu, getMenuInflater());
                    menuBinder.inflateAndBind(R.menu.contextual_action_mode, presentationModel);
                    return true;
                }

                @Override
                public boolean onActionItemClicked(ActionMode actionMode, MenuItem menuItem) {
                    return false;
                }
            });
            return true;
        }
    });
}
Also used : MemoryProductStore(org.robobinding.gallery.model.MemoryProductStore) MenuBinder(org.robobinding.MenuBinder) MenuItem(android.view.MenuItem) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) ContextualActionModePresentationModel(org.robobinding.gallery.presentationmodel.ContextualActionModePresentationModel) ListView(android.widget.ListView) ActionMode(android.support.v7.view.ActionMode) Menu(android.view.Menu)

Example 10 with OnItemLongClickListener

use of android.widget.AdapterView.OnItemLongClickListener in project storymaker by StoryMaker.

the class ProjectsActivity method initListView.

public void initListView(ListView list) {
    list.setOnItemLongClickListener(new OnItemLongClickListener() {

        @Override
        public boolean onItemLongClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
            final Project project = mListProjects.get(arg2);
            AlertDialog.Builder builder = new AlertDialog.Builder(ProjectsActivity.this);
            builder.setMessage(R.string.delete_project_).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    deleteProject(project);
                }
            }).setNegativeButton(android.R.string.no, null).show();
            return false;
        }
    });
    list.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Project project = mListProjects.get(position);
            Intent intent = null;
            intent = new Intent(ProjectsActivity.this, SceneEditorActivity.class);
            intent.putExtra("template_path", project.getTemplatePath());
            intent.putExtra("story_mode", project.getStoryType());
            intent.putExtra("pid", project.getId());
            intent.putExtra("title", project.getTitle());
            startActivity(intent);
        }
    });
    refreshProjects();
}
Also used : AlertDialog(android.app.AlertDialog) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OnItemLongClickListener(android.widget.AdapterView.OnItemLongClickListener) Project(org.storymaker.app.model.Project)

Aggregations

View (android.view.View)11 AdapterView (android.widget.AdapterView)11 OnItemLongClickListener (android.widget.AdapterView.OnItemLongClickListener)11 ListView (android.widget.ListView)9 TextView (android.widget.TextView)9 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)6 Intent (android.content.Intent)4 OnClickListener (android.view.View.OnClickListener)4 ImageView (android.widget.ImageView)4 DialogInterface (android.content.DialogInterface)2 SharedPreferences (android.content.SharedPreferences)2 ConfirmDialog (org.csploit.android.gui.dialogs.ConfirmDialog)2 ConfirmDialogListener (org.csploit.android.gui.dialogs.ConfirmDialog.ConfirmDialogListener)2 ErrorDialog (org.csploit.android.gui.dialogs.ErrorDialog)2 ActionBar (android.app.ActionBar)1 AlertDialog (android.app.AlertDialog)1 PendingIntent (android.app.PendingIntent)1 ActivityNotFoundException (android.content.ActivityNotFoundException)1 IntentFilter (android.content.IntentFilter)1 DataSetObserver (android.database.DataSetObserver)1