Android :: ACTION_UP And ACTION_MOVE Touch Events Passed Through To Custom Views?
Jan 20, 2010I have an activity defined as:
CODE:...................
I have an activity defined as:
CODE:...................
Key Events that occurred in the virtual keyboard can be passed to the hardware, andriod OS or high-level focus view? As with a physical keyboard.
The dpad right event using Bluetooth devices, then it takes my keyboard service would like to pass on Android system or highest focus view(ex. system dialog, menu...etc). but I don't know how.
I have a service that regularly queries a web server for new messages. The service stores the new messages in an arrayList. These messages are implemented using a custom class, storing all kinds of metadata (strings and longs).
An activity then connects to this service to retrieve those messages and display them to the user.
I have an .aidl file that describes the interface that the service exposes.
CODE:..........
The Message class extends the Parcelable class which should allow for the IPC transfer.
The problem is this: Eclipse gives me an error saying that the type of List<Message> is unknown. Any imports are marked as invalid.
I am writing a game using OPENGL, there are several 3D objects in my surface view. My question is: Should each 3D object implement view in order to get touch events? Or there is other way to do this?
View 5 Replies View RelatedActually I'm trying to implement an ontouchlistener into my android (1.5) application. therefore i implemented the "ontouchlistener" into the class, and then i put my code into the: So isn't there a way to catch the touch event before it gets to each of those views?
View 1 Replies View RelatedI'm developing a game for Android. It's got a lot going on but is running reasonably smoothly. That is, of course, until the user touches the screen.While they're touching it, onTouchEvent is called (with action = ACTION_MOVE, x = 0 and y = 0) roughly once every ten milliseconds at what appears to be a fairly high priority, as it absolutely obliterates the framerate. As soon as the touch ends the framerate returns to its nice state.Has anyone encountered this? Is there a way to reduce the rate at which ACTION_MOVE events are generated, or to ensure that they're only generated when there is actual movement, or use a polling method that just gets the current location of the touch? Or even just a way to disable it entirely?
View 4 Replies View RelatedNew to android so please bare with me here
Is it possible to detect all touch events in an Activity and capture it and then in return pass that pass event to another View. For example:
Button 1 and Button 2. When Button 1 is pressed I want to capture that touch/click event and automatically pass that touch event to Button 2, basically with one touch/press you get the click generated and that same click is passed on to the second button automatically.
I'm writing an Android game that needs to receive touch events. My problem is that, whenever the user drags their finger along the screen, so many touch events get sent to the touch event handler (which I think runs as a separate thread) that my frame rate plummets! What's the best way I can limit the number of touch events that are handled per second? For example, if my game runs at 60 fps, I really shouldn't need more than 1 touch event being handled every second. Can I do this is a way that doesn't lose any information (i.e. important information about where on the screen the user touched last)?
View 2 Replies View RelatedI start monkey like this:
monkey -p <MY PACKAGE> --port 4321
(I have already done a tcp port forwarding).
I then use PuTTY to telnet to 127.0.0.1:4321
I can issue a command like tap 100 100 I get a response OK but I see nothing happening on the UI. I have placed a button at that location but I does not receive the touch event.
When I run monkey like this
monkey -p <MY PACKAGE> --pct-touch 100 -v 10
I see touch events being dispatched to the screen.
I'm trying to figure out a way to send touch events to the foreground activity. Essentially I want to write something that allows me to run it from the shell and just say "I touched this co-ordinate", so that I can automate some UI tasks for testing. Essentially what Monkey does, but application agnostic.
I think that android.view.MotionEvent holds the key, but I'm not sure how to run something without view so that I don't interfere with what is on the screen. Perhaps with a service, but I'm unclear how that would work.
Wondering here if there is a way I could trigger an event, so that any library listening for these events (e.g. jQTouch, Sencha touch, iUI, ... ).
If I could extend or use jQuery for such task e.g. $(...).trigger('event') that would be great to know.
Usage example:
I need to debug a few web apps by simulating multi touch with my mouse. This seems a little complicated, so if I could trigger the multi-touch events using Javascript I could therefore test the app more efficiently.
Purpose of the app:
A simple app that draws a circle for every touch recognised on the screen and follows the touch events. On a 'high pressure reading' getPressure (int pointerIndex) the colour of the circle will change and the radius will increase. Additionally the touch ID with getPointerId (int pointerIndex), x- and y-coordinates and pressure are shown next to the finger touch.
Following a code snipplet of the important part (please forgive me it is not the nicest code ;) I know)
CODE:.............
The problem:
A HTC Desire running Android 2.1 is the test platform. The app works fine and tracks two finger without a problem. But it seems that the two touch points interfere with each other when they get t0o close -- it looks like they circles 'snap'to a shared x and y axle. Sometimes they even swap the input coordinates of the other touch event. Another problem is that even though getPressure (int pointerIndex) refers to an PointerID both touch event have the same pressure reading.
As this is all a bit abstract, find a video here: http://www.youtube.com/watch?v=bFxjFexrclU
My question:
Is my code just simply wrong? Does Android 2.1 not handle the touch events well enough get things mixed up?Is this a hardware problem and has nothing to do with 1) and 2)?
I have an Android activity with an ImageButton. I would like to execute some logic when the button is clicked and show a different image for the pressed state, but also receive the touch event on the activity.
By default only the button receives the touch event. If I set the clickable attribute of the button to false then only the activity receives the touch event.
What's the best way to implement the touch event in the activity and the click in the button?
How do you disable all touch events in an Android WebView (or scrolling in particular)? I would like the activity to handle all touch events.
View 2 Replies View RelatedJust wondering if there is an easier way to simply stop ScrollView from being scrolled via touch inputs? I will programmatically get the ScrollView to scroll to top or bottom.
As a last resort, I guess I will have to inherit from ScrollView and capture all the ontouch events. But wondering if there is an easier way before I take this approach?
I have a list activity that creates a header row above the data rows from the adapter. I want to receive click events when the user selects the header or a data row (but my data rows have check boxes in them, so this part is tricky). When I use the touch screen, I get this expected behavior:
1. Tapping on any row causes a click event and a dialog appears.
2. Long-pressing on a data row causes a context menu to appear.
3. Long-pressing on the header row does *not* show the context menu.
However, when I use the arrow keys (emulator) or trackball (G1), I get this unexpected behavior:
1. Selecting any row fails to cause any click events, even though the row's appearance changes like it's being clicked.
2. Long-pressing on the header row *does* show the context menu, which I don't want.
3. Occasionally, it doesn't focus the correct row when I move up or down (e.g. it skips from the header to the last data row).
I'm developing an HTML/Javascript mobile web application using Dashcode. Normally I wouldn't use such WYSIWYG stuff, but I've found it a very rapid development process.
Unfortunately it seems like I can't get it to run on Android's browser currently. The main display loads and all the correct data is pulled from web services, but you cannot press on anything to activate it.
I suspect that the android browser is sending different javascript events, which the Dashcode objects are not configured to pick up.
In addition, the adb logcat debugger refuses to output any log messages from the browser on the emulator, and as such I'm having a very hard time sorting this out.
What events I need to be watching for, so I can iterate over all the touch handlers and duplicate them for the android events, or offer help in any other way on this situation?
If I setOnTouchListener for a view the only events I get are ACTION_DOWN events. What do I need to do to capture ACTION_MOVE events which should occur when the user drags a finger across the view?
View 3 Replies View RelatedI have a custom Android view which overrides onTouchEvent(MotionEvent) to handle horizontal scrolling of content within the view. However, when the ScrollView in which this is contained scrolls vertically, the custom view stops receiving touch events. Ideally what I want is for the custom view to continue receiving events so it can handle its own horizontal scrolling, while the containing view hierarchy deals with vertical scrolling.
Is there any way to continue receiving those motion events on scroll? If not, is there any other way to get the touch events I need?
My phones' display has been broken and I would like to know if there is a pc software that allows me to simulate touch events via adb bridge.
View 1 Replies View Relatedim having a problem getting a custom view that i created on the xml layout file. i have a class named DrawingLayout which extends FrameLayout. it is found in the package Drawing
as stated on this page http://developer.android.com/guide/topics/ui/custom-components.html i used the following decleration in xml
<Drawing.DrawingLayout ... />
but whenever i run the program with that decleration i get a runtime exception error on SetContentView( ... )
is there something im not doing well? If you need any more details please tell me because i cant seem to figure this one out.
Is it possible to nest one custom views within another Custom view?
View 13 Replies View Related*I have used three custom views... playpanel works fine.. but drawHeaderpanel does not workk..*
public class MainPanel extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);...................
Does anybody knows if (and how ) I can write a custom view/widget and then use it in resources in layout defintions?
View 5 Replies View RelatedI am parsing the url to display the contents in it, my requirement i have to display the each content in separate textviews.
For Instance: Let us assume the contents in that url are FootBall, Carom , chess, VolleyBall and so on . I want to display FootBall as a individual textview similarly others. so i cannot declare the textviews in xml what i usually do.
CODE:................
So i planned to create textview via java code
This is my parsing code which parse the url contents and store the result in a string array namely san_tagname; depending upon the length of this variable i want to create number of textviews.
CODE:..................
I am having trouble getting my activity to generate a MotionEvent.ACTION_UP. Probably a beginner's error.
In LogCat, I'm only seeing the ACTION_MOVE event (which is an int value of 3). I also see the X/Y coordinates. No ACTION_DOWN and no ACTION_UP.
I looked everywhere for a solution. I found one question on a forum that seems to be the same as my issue, but no solution is proposed: http://groups.google.com/group/android-developers/browse_thread/thread/9a9c23e40f02c134/bf12b89561f204ad?lnk=gst&q=ACTION_UP#bf12b89561f204ad
Here's my code:
CODE:..........................
I have made a Custom Component in XML, consisting of a button with an imageview stacked on top of it:
<myapp.widget.ClearableCaptionedButton
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Button
android:id="@+id/ccbutton_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|left"
android:textAppearance="?android:attr/textAppearanceMedium"
android:background="@android:drawable/edit_text"/>
<ImageView
android:id="@+id/ccbutton_clear"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dip"
android:layout_alignRight="@id/ccbutton_button"
android:layout_alignTop="@id/ccbutton_button"
android:layout_alignBottom="@id/ccbutton_button"/>
</myapp.widget.ClearableCaptionedButton>
Extract of java source code:
public class ClearableCaptionedButton extends RelativeLayout implements OnClickListener {
...
public ClearableCaptionedButton(Context context, AttributeSet attrs) { super(context, attrs);
// some stuff that works fine
} ..
protected void onFinishInflate() { super.onFinishInflate();
mButton = (Button) findViewById(R.id.ccbutton_button);
mClear = (ImageView) findViewById(R.id.ccbutton_clear);
mButton.setText(""); // error here: mButton == null
}
My problem is similar to this one. When I try to find the views inside the custom compound, findViewById returns null. But, as you can see, i already added super(context, attrs); to the constructor. I am using the custom component directly in xml layout, like this:
<LinearLayout>
<!-- some stuff -->
<myapp.widget.ClearableCaptionedButton
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:caption="to"/>
</LinearLayout>
I created a custom SurfaceView called CaptureView and tried to add it into main.xml file.The application seems to work fine but if I switch from main.xml tab to Layout in Eclipse the text NullPointerException appears instead of layout preview.Does anyone know how this issue could be solved?
View 2 Replies View RelatedI have a set of custom views that I would like to add to a LinearLayout object. However, the first object I add to the layout (I do this dynamically, during runtime) has a OnMeasure method that tries to get as much space as possible resulting in that it get's all the space LinearLayout object. This is correct behavior, but when I then add more objects following that I want the allocated area for the first object to decrease so the others will fit. As it is now, each following object will get zero space, and hence won't be visible.
View 4 Replies View RelatedI have a requirement to create a control similar to UITabBar in iPhone, which is to be present on every activity of my application. UITabBar essentially is a battery of buttons exhibiting a TAB like behavior: every button maps to an activity. I have two solutions for this: 1. In the layout XML for every activity, I insert a <LinearLayout><Button/><Button/><Button/></LinearLayout> element. And then have a common listener class that will handle the button clicks. So, every activity will have an instance of this listener. 2. To create a custom Widget extending LinearLayout class, put all the buttons as its static members and let it handle the button clicks. Include this custom control in every screen.
View 3 Replies View Related