onclick

Android, How can I get text from TextView in OnClick

吃可爱长大的小学妹 提交于 2019-12-10 15:29:51
问题 I have some TextView and each have an OnClickListener . I would like get information in this method to TextView TextView tv2 = new TextView(this,(String)book.get(i),this); tv2.setOnClickListener(new OnClickListener() { public void onClick(View v) { Intent intent = new Intent(Contact.this,Discution.class); //String str = this.getText(); //like this startActivity(intent); } }); How can I do : this.getText(); in an OnClickListener ? 回答1: tv2.setOnClickListener(new OnClickListener() { public void

A better way to OnClick for EditText fields?

回眸只為那壹抹淺笑 提交于 2019-12-10 15:13:45
问题 I have an EditText field, suppose the user has already entered text into it. Then the user wants to come back to edit the text again: the feature I want for this EditText field is that if you select it after it already has text in it, it clears the text for you before you can type something new in. I tried using the EditText field's OnClick method, but this required that I select the EditText field, then click on it a second time, something that isn't obvious to anyone but me. How can I get

Android: How to call onTouch only after an onLongClick?

陌路散爱 提交于 2019-12-10 15:10:03
问题 I have an image, which can be moved around and scaled with pinch gesture.. All this is done inside onTouch() . I want to restrict this and make it movable(and scalable) only after the user has done a longclick on the image.. How do I do this? 回答1: Register a LongCLickListener. If a long click is recognized set a flag to true. In the OnTouch method allow scaling and moving only if the flag is set to true. After the moving and scaling set the flag to false again. Here is some pseudocode: public

click listener on android widget Button

坚强是说给别人听的谎言 提交于 2019-12-10 14:58:10
问题 I am new to android development. I want add click listener on button in widget. I am updating widget in service. Thanks in advance. 回答1: Maybe you should look into making a clickable widget. This involves using: remoteView.setOnClickPendingIntent(R.id.widgetFrameLayout, pendingIntent); 来源: https://stackoverflow.com/questions/15609500/click-listener-on-android-widget-button

Small dead space on a div button in chrome

霸气de小男生 提交于 2019-12-10 14:34:31
问题 I can't explain this one. I've got a div that's a button. I use the :active psuedo class and position: relative; to move it slightly down and to the right when clicked, to give it an animation. For some reason, there is a small dead space on this button in Chrome about half way between the text and edge of the button. The psuedo class still fires but the Javascript on the button does not. If I remove the position relative, the problem goes away. This also happens in Firefox, but the deadspace

bootstrap-select does not proxies click event

旧时模样 提交于 2019-12-10 14:21:24
问题 I had select element: <select id='selectBox'> <option>Mustard</option> <option>Ketchup</option> <option>Relish</option> </select> and set click event via jquery: $('#selectBox option').click(function(){ ..... }); after using http://silviomoreto.github.io/bootstrap-select/ : <select id='selectBox' class="selectpicker" multiple="" data-selected-text-format="count"> <option>Mustard</option> <option>Ketchup</option> <option>Relish</option> </select> I got nice multiply dropdown and all work fine

Ctrl or Shift effects on the `onclick` event of an anchor tag in each browser

ぃ、小莉子 提交于 2019-12-10 13:43:36
问题 I recently discovered that different browsers handle the onclick event differently when the Control or Shift keys are pressed. They diverge similarly on behavior for for following links by clicking the middle mouse button. With the following link: <a href="http://www.example.com/" onclick="alert('onclick');">go to example.com</a> Onclick browser support table Mouse Keyboard Chrome Firefox Safari Opera IE5.5 IE6 IE7 IE8 IE9 Left None yes yes yes yes yes yes yes yes yes Left Ctrl yes yes yes

Android onClick blocking onFling

独自空忆成欢 提交于 2019-12-10 13:33:43
问题 I have an Activity that implements a Gesture Detector to catch the user fling input for navigation to other screens. That was working fine - but - I recently updated a class that derives from BaseActivity to add an onClick function and now that click event seems to block the onFling from being hit. The onClick is tied to a TextView area (in a LinearLayout) I have on my screen. The resultsClick method is wired to the TextView using its onClick property in the XML layout. I've tried changing

Android to detect when you are holding down a button

我们两清 提交于 2019-12-10 13:19:05
问题 I need to be able to tell when the user is holding a button down and when the user lets go. This is different from onClickListener and onLongClickListener. How would i go about doing something like this? For example I press a button that starts a chronometer.(pseudo code) if ButtonIsBeingPressed { chronometer start(); //and keep going } else chronometer stop(); //or on release or something } 回答1: Look into the OnTouchListener it has MotionEvents for Down (press) and Up (release): view

Form not submitting with JS

与世无争的帅哥 提交于 2019-12-10 13:15:44
问题 I have the worlds most simple javascript function: fnSubmit() { window.print(); document.formname.submit(); } Which is called by: <button type="button" id="submit" onclick="fnSubmit()">Submit</button> All is well and good, the print dialog shows up, however after printing or canceling the print I get the following error: "document.formname.submit is not a function" My form is defined as follows: (obviously I am not using formname in the actual code but you get the idea) <form name="formname"