ontouchlistener

How can I add OnClickListener to Drawable in EditText?

北城以北 提交于 2020-01-14 09:18:22
问题 I have edittext and want to add to right "search" icon.. searchTxt.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.search, 0); But how can I add event for click this icon? searchTxt.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { Drawable co = ((TextView) v).getCompoundDrawables()[2]; if (event.getX() > v.getMeasuredWidth() - v.getPaddingRight() - co.getIntrinsicWidth()) { Datas.search = searchTxt.getText().toString(); startActivity

Implementing OnTouchListener on LinearLayout - Android Development

十年热恋 提交于 2020-01-13 15:00:15
问题 public class UnitConverterActivity extends Activity implements OnTouchListener { /** Called when the activity is first created. */ LinearLayout mLinearLayout; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mLinearLayout = new LinearLayout(this); ImageView i = new ImageView(this); i.setImageResource(R.drawable.mainmenu); //i.setAdjustViewBounds(false); i.setScaleType(ScaleType.FIT_XY); i.setLayoutParams(new Gallery.LayoutParams(LayoutParams.WRAP

Embedding ListView inside Gallery

℡╲_俬逩灬. 提交于 2020-01-13 03:02:33
问题 The goal is to implement a Gallery whose adapter returns ListViews (in other words, vertically scrolling ListViews embedded in a horizontally scrolling Gallery). It sort of works after a bit of work, but when attempting to scroll horizontally, the ListView looks very jittery, like there is some stickiness to it being centered. I have not observed this kind of behavior with any other type of View embedded in a Gallery. Here is what I have tried: Initially, I found that the ListView squashed

On Drag Listener multiple IF statements

偶尔善良 提交于 2020-01-12 06:00:01
问题 I'm making a Letter Drag n Drop game (kinda like Guess the Brand) where you have an image and you have to drag the letters into layouts to form the correct answer. At the top, I have Four layouts (layoutAnsw A to D), and in the bottom I have Four buttons (btnTop A to D) I have the OnTouchListener and OnDragListener working fine, except one single thing. What happens when I have more than one similar character (letter)? For example in this image: As you can see, I have to "A" letters that need

Android : ImageView getID(); returning integer

≯℡__Kan透↙ 提交于 2020-01-11 15:47:26
问题 I've set up an onTouch class to determine when one of my 40 buttons is pressed. The problem I am facing is determining which button was pressed. If I use: int ID = iv.getId(); When I click on button "widgetA1" I receive the following ID: 2131099684 I would like it to return the string ID "widgetA1" from:game.xml <ImageView android:layout_margin="1dip" android:id="@+id/widgetA1" android:src="@drawable/image" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>

Android : ImageView getID(); returning integer

前提是你 提交于 2020-01-11 15:47:06
问题 I've set up an onTouch class to determine when one of my 40 buttons is pressed. The problem I am facing is determining which button was pressed. If I use: int ID = iv.getId(); When I click on button "widgetA1" I receive the following ID: 2131099684 I would like it to return the string ID "widgetA1" from:game.xml <ImageView android:layout_margin="1dip" android:id="@+id/widgetA1" android:src="@drawable/image" android:layout_width="wrap_content" android:layout_height="wrap_content"></ImageView>

Android : Get view only on which touch was released

别等时光非礼了梦想. 提交于 2020-01-10 04:26:04
问题 I am in a tricky situation, hope you can help me with it. I have few views (TextViews), horizontally placed one after another in a linear layout. When I press on textview1, drag my finger to any other textview and release touch, I want to be able to get the view(textview) on which the finger was lifted. I went over the TouchListener api, it says that every event starts with a ACTION_DOWN event action. Since other textviews won't fire that event, how can I get the reference to the textViews on

Android Click button behind another button

你。 提交于 2020-01-07 04:33:06
问题 I have 6 Buttons (green) that open apps. On top of this buttons there is another button which I use for swipe listener. If no swipe is detected (click) I want to click green buttons else perform swipe action triggered by red button. here is my TouchListener taken from here public class OnSwipeTouchListener implements OnTouchListener { private final GestureDetector gestureDetector; public OnSwipeTouchListener (Context ctx){ gestureDetector = new GestureDetector(ctx, new GestureListener()); }

onTouchListener adding to all list elements instead of only one

两盒软妹~` 提交于 2020-01-06 18:12:11
问题 Guys I'm having a strange problem: In a chat application I have a ListView and an Adapter to deal with it. If the user sends an image from gallery I will show a thumbnail on the bubble speech and add a onTouchListener to open this image on full screen. The problem is: When I'm adding the event listener it is adding to all my ImageViews! So if I click on the last imageView it is showing the right image on the full screen, but all other's before are showing the same image. I reviewd the code a

SwipeToDismiss works only on Buttons?

拜拜、爱过 提交于 2020-01-06 15:10:03
问题 I am Using SwipeDismissTouchListener in my Code but it seams to work only for buttons , not for TextView, RelativeLayout etc. How to use it for other View Types? 回答1: Got the Solution :) It works for all views required they should have an onClickListener implemented. Buttons tend to have that by default :) 来源: https://stackoverflow.com/questions/20897288/swipetodismiss-works-only-on-buttons