Android Gallery on image change - java

Hi I'm writing a gallery library for a few projects i'm working on so far i have slide show and buttons for navigating the gallery besides using fling. I'd like to hide the navigation buttons after say 3 seconds of not swiping. So the idea is once scrolling stops, start a runnable to set the imageviews view to gone after the 3 seconds and then once scrolling starts again set the view to visible again.
How can i listen for fling in android Gallery class
Gallery g = (Gallery) findViewById(R.id.gallery);
Thanks

There is an inherited method called onFling which is perfectly suitable for that. Just let it call an interface's method and provide all the parameters you're needing.
Using an interface as listener is pretty common when coding for Android.

Related

IN Android TV when talk back is turned on the Onkeylistener is not being called

I have a custom grid view using Canvas component in my app. it works good normally but when i turn on Talkback the onkeylistener is not getting called and the navigation is not happening in android tv...while the same navigation works fine in fire tv..
do some one have idea why this might happen...
I have tried setting this.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); while drawing the view but it did not help.

How to Show Custom View (FAB) On All Screen in Android

I want to show my custom floating button on all screen in my app without putting it in each activity.
Do we have some Global Activity like put a code once will show the Custom View all screen and hide/remove when app killed
I tried lot of things like Screen Overlay display over all apps
Please check code here - How to display custom view on all screen in android from my library
I've never tried to do it the Java/Kotlin way. But have you considered using Fragments?
You can declare xml layout and code for one Activity with a FrameLayout container and an FAB. The container holds all your screens and they switch between each other in the container. The FAB is on top and therefore will be displayed no matter the screen.
The Activity has a reference to any screen that might be displayed in it, so the FAB can behave accordingly.
Not sure if this helps. Perhaps if I see some pictures, I could suggest better.
Related Read:
Creating a fragment: here
Fragment Transactions: here

java android view structure

Just a simple maybe stupid question.
Is it ok to use multiple activities at once in an android application using an Inflater? I want to have multiple views on my screen without losing the previous view. For example, a user clicks on a button and a information screen shows up. Start Intent would convert the whole screen to the information screen activity.
Using an Inflater works but I'm just wondering if its the right way to display multiple views. Thanks in advance.
You should be using Fragments for this. Each fragment has a view/layout and you can move them in & out of your main view as you require. There are many tutorials
You can set the visibility of the views, e.g.:
Button b = (Button)findViewById(R.id.button);
b.setVisibility(View.GONE);

How do you make custom widgets?

When using developing Widgets for Android it seems you are not able to add your own custom View classes to a AppWidgetProvider.
For example I created a custom class which extends View, this works fine when used within an Activity but the moment I add it to a Widget I get a "ClassNotFoundException" because Android seems to only allow a set of certain system widgets to be added.
I have seen some apps which look like they have made there own custom widgets. For example there is one that brings up a radial menu when clicked which shows application shortcuts. How are these being implemented? Is there a work around to using my own custom widget? They seem to have a canvas which they are able to draw on within the widget.
Okay quick example https://market.android.com/details?id=zombiesinthelab.widgets.droidpetwidget&feature=top-paid
So this widget is being done by just drawing ImageViews and updating them periodically opposed to using a canvas to draw the frames?
Android Widgets can only contain Layout-Widgets supported by RemoteViews. See this list:
A RemoteViews object (and,
consequently, an App Widget) can
support the following layout classes:
FrameLayout
LinearLayout
RelativeLayout
And the following widget classes:
AnalogClock
Button
Chronometer
ImageButton
ImageView
ProgressBar
TextView
> Descendants of these classes are not
supported.
Pay attention to the last sentence. You can not change this behaviour, it is hard coded in android.
I have not much idea on how to create widgets but following links can definitely help you:
1) http://developer.android.com/guide/topics/appwidgets/index.html
2) http://developer.android.com/guide/practices/ui_guidelines/widget_design.html

Android: many activities on single screen?

I'm creating my first app for Android device and I was faced with a challenge... I want to create fixed bottom bar on every screen of my application (something similar to bars from tunein radio).
However I do not know how to make bars which are fixed on every activity (bar do not load when new activity is loaded but is permanent on every app screen). I do not want to <include> my bars in every activity (I've tried this solution but my bars were loading with activity).
Is it possible that this is Activitygroup and only middle activity is changing? If so how can I do that?
PS.
What book or tutorial do you recommend ;-)?
tunein radio bottom and top bar image #1
Use fragments api. It perfectly fits your needs.
Look at ViewFlipper. It lets you manage multiple views. You'd have one activity that would watch your button bar and flip views in response to buttons.

Categories