Android increase gridview click speed - android

I'm using a GridView in Android. I need to register as many clicks as possible, but gridview reacts to clicks very slow, even if there is no acutal code to execute... is there a possibility to speed this up?

Depending on the application, you might want to code up a custom component.
I had a similar problem and replaced the old gridview with a component based on TableLayout. It was more work, but was worth it in the end (faster and more flexible).
Here's a handy article to get you started:
http://developer.android.com/guide/topics/ui/custom-components.html

Related

Nativescript Vertical Screen Slide / ViewPager

What is the easiest way to implement a screen slide in Nativescript like shown in Android Viewpager , but in a vertical direction ? Another example of this functionality would be the rss reader feedly where you can change rss feeds by swiping up/down.
The page should allow vertical scrolling to the top/bottom and then transition after a certain treshold.
I already encountered nativescript-slides, which can only do horizontally sliding.
So is there a "nativescript" way or do i have to implement it as native android/ios feature (for example by this) ? In either case a sample on how to integrate it in nativescript would be great.
Update
Recorded an example:
taken from this Repo with Android native code. The outstanding PR made changes to offer vertical scrolling in the list. But the repo seems to be outdated and a bit buggy.
I can provide more info later but there's a new plugin implementing the native controls for android and iOS for slides/carousel her https://github.com/alexrainman/nativescript-carousel-view and vertical swiping is on his radar, I think he might even be close to completing that.
To give an answer for anybody interested in above nested scrolling animation:
For Android I had to implement the native ReyclerView in Nativescript in favor of the NS buildin ListView. It is an optimized view structure which among other things allows nested (vertical) scrolling and can be used as replacement for an ordinary list.
Together with https://github.com/alexrainman/nativescript-carousel-view works like a charm!
Anyone that ends up here still looking for ways to achieve this.
I spent a lot of time trying to figure out a way to achieve this and tried to find ready plugins for this. Also tried to use the plugin from Alexrainman but eventually gave up since the plugin was not up to date with the current nativescript-version.
My solution:
I used radListView as a basis for this implementation and leveraged the methods and events on the radListView.
By using scrolled-event I gathered data for the use of the scrolling feature: scroll Speed and scroll direction. (These might be also taken from the event data, but since I did not find the event details from the Nativescript-documentation I gave up trying to guess where to find this data on the event-model).
Then I also saved the fixed height of one item on my list (The height I fixed to screenHeight-200).
With all this info, I managed to hook the event "ScrollDragEnded" and add logic that makes my list behave like a vertical slider. Moving on the list by method "scrollToIndex" and figuring out which index to scroll and when by leveraging all the data mentioned above.
This is the way I managed to make a pretty good vertical slide.
Good luck!

how to determine where a user clicked at on an ImageButton via Android?

this is my ImageButton. my confusion is that i do not know how to determine whether the user clicked on the Login half, or the Sign up half, so i can take them to the respective Activity. i would be incredibly grateful if somebody can 1) name a resource i can use to learn on my own, or 2) explain the process of finding view locations and any possible algorithms used to determine if a click was in bounds of a specific portion of a View or not.
You should divide your button into 2 different ones, and process clicks separately.
Have 2 image buttons and try to achieve the same look and feel you want.
In your case, even though this kind of thing is doable. It is expensive and complicated and unnecessary. And you will have problems with styling of the buttons (eg: focus)
Edit:
Yes I understand, But I suggest you not to over complicate things. Because, your device has limited resources (eg: battery),
But you can still get the experience on how to create a circle like button with two sides on it, using 2 buttons which is still exciting :D.

Newbie in Android development. Implement several different processes in an activity

I'm begining to learn android development, and I'm trying to make an app just to learn the language and philosophy.
This app, has to show an image in the middle of the screen, a button below, and a chronometer in the right side. When the app starts, the chronometer has to begin a countdown. When the user press the button, a blur effect has to be applied to the image, and the seconds left to finish the countdown increase by 10.
I almost know how to program the blur efect to the image, the button press, and the countdown and increase by 10 whenever the button is pressed. But I'm not sure about putting all together.
As far as I know, it should be done by designing an activity, and putting inside the activity the image, the button, and another image or a set of changing images or text for the countdown clock. But as I advance in my studied, today I have read that in order to manage different actions in an activity it is neccesary to do it by using fragments. And I have found much complex programming fragments than activities.
So the question is: can I make what I'm trying to do by a simple activity and defining classes and methods for the image effect and the countdown clock or have I to make it with fragments?
Thank you very much.
today I have read that in order to manage different actions in an activity it is neccesary to do it by using fragments
To be blunt, either you either misunderstood what you read, or you are reading the wrong material.
can I make what I'm trying to do by a simple activity and defining classes and methods for the image effect and the countdown clock
Yes.
have I to make it with fragments?
No. It is possible that the whole UI might be a fragment, particularly if it might be shown alongside something else in some cases (e.g., a tablet) and not in others (e.g., a phone). And there is nothing stopping you from making that UI using several fragments, though that would be rather unusual.
As others have already conveyed, no need to go with fragments.. Activity wud suffice.. As far as putting it together is considered, I guess you need to learn more about layouts.. Layouts are the files which basically help you put things on UI as you want it to look like.. There are plenty of material available online for understanding layouts.. Happy learning.. :)

How to implement Android 4.0 like swipe to dismiss functionality in ListView?

I'm working on an app in which I would like to implement swipe-to-dismiss functionality in the ListView - similar to what we see in Android 4.0's notification bar, recent apps list or browser tabs. I want to run the app on the devices running Android 2.2+. See the following image. I also want to change the transparency of the item being swiped-away - just like in ICS.
I checked the source of the ICS web browser on http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android-apps/4.0.1_r1/com/android/browser/TabScrollView.java?av=f but couldn't figure out which class is particularly responsible for implementing this functionality.
Can anyone point me in the right direction here? Can we do this using Android Compatibility Library? Please let me know. Many thanks.
I've thought about implementing such a feature as well, but I haven't done it yet. So the only thing I can provide are some ideas on how I would approach that problem. If I've eventually written some code I will post it here.
The main class needed is a custom Adapter which extends a ListAdapter (ArrayAdapter, SimpleCursorAdapter etc.).
The adapter applies a View.OnTouchListener to all of its Views.
Whenever that listener detects a horizontal scroll dx, it calls concernedView.offsetLeftAndRight(dx) (which will make the view draggable). Of course the adapter has to save the current horizontal offset for the view. If the user was dragging a view and removes his/her finger from the screen, the touchListener will detect this as well and start a slide back animation. Using the current offset we can also calculate an alpha value, so the view will fade out when it approaches the screen borders.
If one list entry is eventually dismissed by the user, it becomes a bit tricky, and I'm still not sure how I would implement the following action: The list content has to be updated (or the adapter has to ignore the dismissed entries) and the views that were below the one that was dismissed must hover upwards in order to fill the gap. I think it might work to let the ListView load the new content, but that would fill the gap instantly. In order to avoid that, I would then start an animation that lets all the concerned views hover from their old position (where we still had the gap) back to their current position (where the gap is filled).
These are just some of my thoughts on the issue that might help some people getting started on working on the problem. Like I said, I'm probably going to implement that sometime in the future and of course I will post the code here.
I would appreciate any feedback in the comments, but I don't want to thorougly explain every single aspect of my idea, that would take me too much time ;)
I know this is quite an old question, but for anyone still searching for this, you can have a look at Roman Nurik's library here: https://github.com/romannurik/Android-SwipeToDismiss
This shows how to create the required behavior for list-view as well as for normal views.

How to Have multiple buttons inside Android SlidingDrawer Control

I am making a quiz application in which i am planning to use the SlidingDrawer control for displaying different question numbers. Clicking on a number will allow the user to jump to a specific question.
I have implemented the sliding drawer control but it is able to display only 6-7 buttons inside it depending on the screen size. Trying to add more buttons to it gives an exception.
I tried using a GridView inside the SlidingDrawer but i keep getting an error.
Is there anyway i can have around 20-30 buttons inside the SlidingDrawer control arranged in a grid like manner ?
Please give suggestions on any other way i can implement similar functionality in a way that doesn't take up much screen space ?
Yes, it's possible, as a matter of fact previous Android versions (1.6 if I'm not wrong) implemented the application Launcher that way.
Search the source for that version and you'll have a working sample.

Categories

Resources