I am working on a Fragment application in Android 2.2. It so happens that most examples have a list on the left side that opens up a detail page when clicked.
However, does anyone know if this is by default or I can have something else other than a list like take for instance button widgets?
Thanks in advance.
Yes, you can have something else there. Note that to have the list you need to extend the ListFragment.
So you have two choices:
Extend Fragment and do what you want. This is good if what you want does not fit into the List ideology at all.
Extend ListFragment and use a custom Adapter. Then you can reimplement Adapter.getView and draw whatever widget you want, including the buttons.
Related
I am coming from iOS. I want to create a picture slider and instantiate it different activities. I want to reuse the code that controls the slide and detects the gestures, so I can just instantiate the same class in each activity.
In iOS I do that by just adding controller logic in a view that I instantiate. How would I do that in android?
Thanks
Ok, after a few days of googling and thinking outside of the iOS mindset I found the solution, which ironically was the same as iOS.
Extend the View class. You can also extend a fragment but that has its own tradeoffs, mainly being that you can't instantiate a fragment inside another fragment. So to not limit your reuse of the class extend views. The downside to that is that with views you need to manage states, meaning that if the user rotates the view, you need to be able to store and restore the state of your view items (text view contents for example).
These links might help you out
https://www.youtube.com/watch?v=YIArVywQe8k
http://www.vogella.com/tutorials/AndroidCustomViews/article.html
http://developer.android.com/training/custom-views/create-view.html
I am a novice in developing android app ! I am working with Android Studio!
Want to implement a tab-panel in which some of the tabs (as this) will contain listview to hold some data or image from a json Webservice! While the data comes from internet connectivity so there is performance is a issue for me!
I have got two types of way to implement tabs in android! One is listactivity & other is fragment! I just want to know which of these two way is efficient for implementing tabs on android??
A listActivity is an activity, and you cannot bind a different activity to each tab-panel, but you can put a different fragment on each panel (or use a single container, and just replace the fragments there with transactions).
You can also use another fragment to display the tab-interface at the top, which remains constant as the contents below changes. Something you couldn't do if you were switching activities.
I'm currently designing the following 2 pane layout and I'm wondering on how to implement it.
Link to Wireframe
So far, I made a two pane activity. On the left is a custom ListView fragment. On the right is a detailpane. The detail pane is what I'm having trouble implementing. I don't know how to create a tab view that doesn't use the actionbar and I'm curious if the best way is to use a ton of fragments for the detailpane or just add change the data dynaically.
[The reason I don't want to use the action bar is that I'm using it for my Help/Refill buttons]
So what tools/tutorials/advice can anyone recommend in implementing this?
Additional information:
Categories or the Tabs will be based on a JSON array.
The listview inside the tabs will be filled with items from a JSON array.
Let me know if you need any more information.
I am currently using a FragmentTabHost and it's just perfect!
You can have your ListFragment and a simple Fragment with your details.
And use your FragmentActivity to communicate with them.
You just need to override the onAttach method of your activity which is called when a Fragment is displayed.
I'm using SlidingMenu lib to implement a sliding side menu. I can add a list view, or other views to the menu as: menu.setMenu(R.layout.static_list_layout); and it's working perfectly as wanted.
My needs are more than a static list, I used to have an activity that relies on an empty list_view and programmatically fill up the list according to user profile, the contents are dynamic.
Just as facebook left menu, where user groups are listed. I want to attach this same activity to dynamically fill the list in the menu. Is this possible? Any example code?
Even if you find a way to do it you shouldn't use an Activity for what you are describing.
The better option is to use a Fragment class, a quick search found me an example here:
Dynamic UI with sliding menu and actionbarsherlock
The good thing about fragments is that they have pretty much the same lifecycle as activities so you get all the things that an activity has.
The other option is to use your own view (that is extend it).
you can create a class that extends FrameLayout for example and add an inflated view to it. This will also enable you to write additional logic based on dynamic properties.
However i suggest you to look into fragments and do it the "fragments" way.
Activities span the full screen, this is not possible.
You can try to use a fragment however.
I have a group of tabs. In one of the tabs, I want to display two different types of functionality.
So my question is it better to implement a activity group with child activities or just create a view flipper and switch between views.
ActivityGroup is used to manage one or more activity example. if two different activity have different implementation but the user want to see on sharing screen basis means in first half user want to see some thing and in second have some other thing. In that case ActivityGroup comes to play
ViewFlipper can be used if you want to periodically change the views. Say like an automated flipping book of some sort. Though a custom-adapter gallery is much better at this.
Both have different purpose. It depends on your requirement you will choose any of them.
i would go with a view flipper. you probably dont need the whole overhead of creating another activity. but that way will make your single activity that will hold them a bit larger. so also maybe try to implement some of the functionality inside the views you will be adding.
hope this helps.