onlongclicklistener

ViewPager and longclick

心不动则不痛 提交于 2019-12-22 12:41:24
问题 I have a layout that is over top of a viewpager. The viewpager is functioning as a dynamically changing background. Upon a long click of the viewpager (long clicking the background), the foreground elements should disappear. I put a long click listener on the viewpager, but it doesn't respond to this out of the box. This linked answer seems to touch on the subject, but I'm not sure how to implement it, help? https://stackoverflow.com/a/11303508/727429 I'm also experimenting with other UX

OnLongClickListener not working

心已入冬 提交于 2019-12-22 10:17:23
问题 I have an ImageView . I need to use onLongClickListener for ImageView. When I use this code nothing happen. Code: gallery=(Gallery)findViewById(R.id.gall1); gallery.setAdapter(new ImageAdapter(MainActivity.this)); gallery.setOnItemClickListener(new OnItemClickListener() { @Override public void onItemClick( AdapterView<?> parent, View v, int position, long id) { // TODO Auto-generated method stub final ImageView imageView = (ImageView) findViewById(R.id.image1); imageView.setImageResource

onLongClick listener for group of buttons in Android

时光总嘲笑我的痴心妄想 提交于 2019-12-22 10:11:58
问题 In my Android application, I want to create a fragment that works like a keypad. I have one function which handle onClick for all 9 keys. I want to know is there anyway to write just one function to handle onLongClick for all these 9 keys too. here is layout xml : <Button android:id="@id/testButton" android:layout_width="70dp" android:layout_height="55dp" android:layout_margin="2dp" android:background="@drawable/keypad_round_button" android:text="1" android:textColor="@color/black_1" android

Android AdapterView Click Listener Parameters - position & id

末鹿安然 提交于 2019-12-19 10:08:57
问题 I'm setting a long click listener on a listview and I want to use the index of the clicked item to retrieve the corresponding object. Method signature and parameter definition according to android docs public abstract boolean onItemLongClick (AdapterView<?> parent, View view, int position, long id) Parameters parent The AbsListView where the click happened view The view within the AbsListView that was clicked position The position of the view in the list id The row id of the item that was

setOnClickListener and setOnLongClickListener call on single button issue

左心房为你撑大大i 提交于 2019-12-18 12:24:46
问题 I need your help if any one can be, it will be great thing for my solution. I don't know is it possible or not, but I want to try to fix this out any how.. Actually I want to implement two method on single button click event, its simple click and long click, here my code :: homebutton = (ImageButton) findViewById(R.id.home_icon); homebutton.setOnClickListener(new OnClickListener() { public void onClick(View arg0) { Intent intent = new Intent(context, MainActivity.class); startActivity(intent)

Use both onClickListener and onLongClickListener in listview Android 1.6

跟風遠走 提交于 2019-12-18 11:40:56
问题 I am using both onClickListener and onLongClickListener for a TextView in a ListView . I see that in Android 1.6, the long click listener is fired along with the on click listener meaning both are fired when I long click. But this is not the case in the future versions. Is there any fix for this? @Override public View getView(int position, View convertView, ViewGroup parent) { if (convertView == null) { LayoutInflater inflater = getLayoutInflater(); row = inflater.inflate(R.layout.row, parent

Stop OnLongClickListener from firing while dragging

孤人 提交于 2019-12-18 04:46:12
问题 I have a custom View with bitmaps on it that the user can drag about. I want to make it so when they long click one of them I can pop up a context menu with options such as reset position etc. In the custom View I add my OnLongClickListener: this.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { // show context menu.. return true; } }); And override onTouchEvent to look something like this: public boolean onTouchEvent(MotionEvent event) {

Handle on item long click on recycler view

邮差的信 提交于 2019-12-17 18:15:47
问题 I have an adapter that customizes a recyclerView and I want to open a popup menu on long click event on recyclerView 's items. How can I do this? 回答1: This has already been answered here. Anyway, you can do it like this: class ViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener, View.OnLongClickListener { private Article article; private TextView nameTextView; public ViewHolder(View itemView) { super(itemView); itemView.setOnClickListener(this); itemView

how to implement a long click listener on a listview

亡梦爱人 提交于 2019-12-17 02:09:05
问题 I want to add OnLongClickListener on my list view. Whenever the user long press the item in list some action should be performed, But my code does not catch this listener. Please let me know where I am going wrong. The similar code works for setOnItemClickListener very well. Here is the code : listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { public boolean onItemLongClick(AdapterView<?> arg0, View v, int index, long arg3) { // TODO Auto-generated method stub Log

setOnLongClickListener in kotlin android

橙三吉。 提交于 2019-12-13 23:56:22
问题 How can I use setOnClickListener in each item in my ListView ? my xml : <ListView android:id="@+id/tv1" android:layout_width="match_parent" android:layout_height="wrap_content"> </ListView> 回答1: in your kotlin activity: override fun onCreate(savedInstanceState: Bundle?) { val listView: ListView = findViewById(R.id.yourListViewId) listView.onItemClickListener = AdapterView.OnItemClickListener { adapterView, view, i, l -> //YOUR CODE HERE } } 回答2: Nothing like getting to the party late. We are