Android TV how to make a tab on the top of screen? - tabs

I want to make a tab on the top of screen like this :
I know that tabLayout and viewPager can solve it on the phone. However, how to do on the android tv?

There are several ways you could do this - but I think the short answer is no matter what you do, it'll have to be custom. So far leanback is the only framework offered by Google for any TV specific components and that framework only provides you with a left navigational drawer.
I can offer one solution for if you're using leanback. You could use a BrowseFragment with a custom TitleView which has tabs and keeps track of the focus of the tabs within. As long as your custom view implements TitleViewAdapter.Provider then you can use it with a BrowseFragment as the TitleView. The benefit to this is that you can have it automatically animate in and out from the top with little additional work.
As for the custom view, you can specify focusRight and focusLeft on each tab and have an listener onFocus or onClick to swap out the fragments in the BrowseFragment. This class in leanback shows how to swap fragments in the BrowseFragment (specifically PageRowFragmentFactory).
I would highly recommend you clone the leanback showcase app that the Android team put together and play around in that.
For the specifics of customizing the TitleView, it'll look something like the below:
Create your custom view
class YourTitleView extends RelativeLayout implements TitleViewAdapter.Provider {
... do custom view setup/logic here ...
}
Create an XML file named lb_browse_title.xml. This overrides leanback's layout which they use to create their TitleView.
Put your title view in this lb_browse_title.xml file and ensure it has the id of #+id/browse_title_group. This is so leanback knows to grab your title view.
<com.your.android.app.views.YourTitleView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/browse_title_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
style="?attr/browseTitleViewStyle" />
Then create a Fragment that extends BrowseFragment and it should apply your title view automatically. Please refer to the leanback-showcase app for how to get a BrowseFragment up and running.

Related

When to use Screen, Stage, and Group in LibGDX

I have a main menu screen, which has 4 options, New Game, Load Game, Options and Exit.
Then:
New Game has more options such as difficulty, # of players + Start button.
Load Game has multiple saves to choose from together with Load and Delete options.
Options has Graphics level and Volume radio/ slider + Apply, Discard buttons.
At last, the game screen would have a pannable game window, together with an overlaying UI on the side of the screen.
My problem is, I don't know what class to use for those UI parts.
From this answer I understand that Screen is a full UI page, but it seems that creating a new Screen and then a Stage for each of those main menu options seems like an overkill, but maybe that's the way to go. I don't know if I should use Group and show/hide those depending on what the user clicks. I was also told to use Table to lay out the game screen. I'm utterly confused by all the guides I've found online. Every one seems different than the other.
The documentation is really good, but it never states how the individual parts are meant to be integrating with each other.
Is there any consensus on how to use those classes in LibGDX? Or is it a personal preference?
Screen is core libGdx part that represents one of many application screens, such as a mainscreen, a settingsscreen, the gamescreen and so on.
mainscreen may contains buttons like settings, play, level that help you to redirect on other screen.
settingsscreen may contain back button that redirect to previous mainscreen and other ui element like sound button, music button, language selection button.
It is hard to maintain different UI Screen in one ApplicationListenercontext with different required lifecycle.
so there is a Game class and Screen interface that helps to display one active screen at a time on device screen.
I think you've clear now, why we need different screens.
Now how I design one Screen Like MenuSceen that contains menu buttons, game name and similar element that act as HomeScreen.
You can use scene2d, a 2D scene graph for building UIs using a hierarchy of actors. Stage and Group are core classes of scene2d.
Stage class has a camera, SpriteBatch, and a root group and handles drawing the actors and distributing input events.
Group class is an actor that may have child actors.

How does TVJS detect swipes on the Apple TV remote?

I am building an app using TVJS and TVML for Apple TV. Is there an event to help me detect when the user has swiped the siri remote's touchpad? When I'm showing an image full-screen and the user swipes, I want to move to the next/previous image. But I can't seem to find any event for detecting these swipes. Thanks!
I don't think that you can 'detect these swipes' and react with them manually, TVML and TVJS use standard templates and have particular interactive components that can be laid out on screen and then the Apple TV handles moving between those elements by interpreting the commands from the control.
TVJS only allows you to listen to a limited number of events
enum TVElementEventType : Int {
case Play
case Select
case HoldSelect
case Highlight
case Change
}
You should be able to use the functionality you described by using the correct templates or elements, such as the OneUp template.
Without knowing how you've implemented this so far, there isn't anything else I can recommend. please show the code you are using for more accurate advice

Adobe Air - Starling/Features | Controls and device simulator

I have few questions here, regarding creating app in Adobe Air using Starling and feathers.
I created yet a very simple app, which has Feathers list controller with static data provided to its dataProvider. According to the code it should work fine, but there are three major issues I am facing.
1: Touch/Click Positions
I am using:
list.addEventListener( Event.CHANGE, list_changeHandler );
Now the problem is, clicking coordinates are not correct. Clicking on 3rd Item triggered 4th item, to trigger 3rd, 2nd item needs to be clicked it's half way through etc.
2: Nothing, without Theme
I am using a custom theme, came along with a tutorial. If I don't use the theme, I am unable to see anything on the screen, somehow.
3: Resolution (Device Simulator) Problem
Though buggy, but it works with Theme, but my app doesn't fit with the resolution for each device simulator. Either its, iPad or iPhone 4 or any android simulator.
Also, can anyone please also explains, what is significance and use of Context3D render mode in starling class.
Any help is appreciated:
Thanks in advance
Waqar Iqbal
Starling is a Stage3D framework that displays content directly on graphic card using Context3D. Everything displayed by Starling is always under the regular display list. Feather is a component framework based on Starling.
Stage3D cannot handle any mouse operations so Starling and Feather simulate all their mouse event (those mouse event never really happen anywhere, they are created by calculation of mouse position on the stage)
not sure, never used Feather
Starling does not handle screen density and dpi calculation, if you want your app to fit any screen you'll have to handle it yourself.
I think you should see the example carefully. if u want to use any feathers component either you have to use feathers theme or custom theme.
if you use feather theme you need to provide theme path and before using any component you need to initialize that theme.Then use component any where.without theme you will not see any thing.
1: Touch/Click Positions
please provide minTouchHeight in class theme of DefaultListItemRenderer like:-
renderer.minWidth = this.gridSize;
renderer.minHeight = this.gridSize;
renderer.minTouchWidth = this.gridSize;
renderer.minTouchHeight = this.gridSize;
2: Nothing, without Theme,
3: Resolution (Device Simulator) Problem
Follow the example given in feather library
feathers-2.1.1\themes\MetalWorksMobileTheme\source\feathers\themes

Add Swing objects in Play 2.0 framework

Good afternoon,
I want to know if it will be possible to add Scala Swing objects (especially JFrame objects) in a Play 2.0 application, I look for something like this but I haven't found nothing.
I need a Text Area that the user can write, and after that when he/she submit, I need to create an instance of a Scala class which after that it will show in a JFrame are (if I can) something related with the textarea input.
I can do the textarea form with HTML but the other part I don't know how to do it if not with JFrames.
Are many other ways to do this?
The example of what I can do is (it's a App related on Lambda Calculi):
x ---> create a Var elemnt and display it in a JFrame
\x.x ----> create a Abs(Var,Var) element and display it in a JFrame
...
Can anyone help me?
Thanks in advance
Piotr's comment is correct; the two technologies (HTML and Swing) are very separate. I'm not sure exactly what you're trying to accomplish; however, it sounds like what you want to do is possible via Javascript. A good tutorial for Javascript can be found here: http://www.codecademy.com/tracks/javascript. Javascript is also very easy to integrate into a Play project; you can place your Javascript files in your project's /public folder and reference them from your HTML files using <script> tags.

How can you present modal UIViewControllers in MonoTouch using MvvmCross?

By adding IMvxModalTouchView to MyView, let the view become modal. But, I cannot change it at runtime. i.e. MyView must be modal every time. Is it possible to make it more flexible, let say, Show(MvxShowViewModelRequest view, bool isModal); ?
This area of MvvmCross is called "preesentation"
Other Mvvm frameworks may refer to it as "INavigationService"
Within MvvmCross, the presenter on each platform is 100% overrideable. Some examples and source code links are provided on http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html
If you want to implement some custom navigation hint, then:
all ShowViewModel calls have an presentationHint parameter - https://github.com/MvvmCross/MvvmCross/blob/v3.1/Cirrious/Cirrious.MvvmCross/ViewModels/MvxNavigatingObject.cs#L40
the presenters receive these hints in the PresentationValues property of the MvxViewModelRequest in the Show call