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]);
}
});
}
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));
}
}
});
}
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));
}
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;
}
});
}
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();
}
Aggregations