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.
Related
I am making an app which has a navigation drawer. This navigation drawer has 50 menu items. These items have the same layout, same activity but different data.
I want to implement ViewPager in my app so that the user could swipe left and right (manually and automatically).
Issue: I am facing an issue of how to implement this. The activity (for these menu items) has its own methods and functionality. A ViewPager can slide fragments but my issue is that since all of these menu items have the same layout and functionality then it would be much better to use one fragment whose data change with swipes for each menu items.
I don't know how to approach this. Please guide me.
You can do it by using a recycleView,and you will need an arrayAdapter which will help you adapt the data accordingly and you will need to have a separate class that will have all the data you want, you can also have different constructor in that class. You can check this to know more https://www.codexpedia.com/android/a-very-simple-example-of-android-recyclerview/
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 have been using this link to implement my two screen tabbed view,
http://developer.android.com/training/implementing-navigation/lateral.html
but my problem currently is that this demo only shows how to implement separate views on each tab such as a single TextView on each, whereas I wish to implement separate fragments on each tab that can interact with each other. For example, if a button is clicked on one fragment, I want it to change the text of a TextView on another fragment in the separate tab.
Currently I am using ONE fragment to implement both views and this is becoming complicated, because I can only do modifications to a certain view in the actual inflater of the view in the onCreateView method, rather than in the entire class.
So basically I want to separate them into 2 fragments and have them be able to interact with each other, but I am not sure how to configure them in the onCreateView method to work with the demo in the link I provided.
Thank you for any assistance you may have!
You can attach individual Fragment instances as pages of a ViewPager (instead of just simple views) using the FragmentPagerAdapter (docs link).
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.
I am developing an android application in which I have creted a TabActivity. For each tab I am using a separate activity and a separate layout file. Actually this activity is a details screen which shows customer information. The user can click on an item in a listview activity in order to see customer's detailed info in the tab acticity. There he can use navigation buttons to navigate through the customers In a few words, if the listview displays 10 records and the user clicks on the first item the customer details.tabactivity opens and displays detailed info. Using the navigation butons the user can see the next or previous record.
Now, I would like to use a viewflipper in the details screen in order to use animations while navigating through the records and in the end. to use fling gestures instead of buttons. Nevertheless I haven't found a proper example of how to add a tabhost/tabactivity in the flipper. I also thought to create the tabs using one layout in order to add it to the viewflipper but then I have no way to create the tabs inside the activity that hosts the viewfliper.
Any help would be apreciated. Thank you in advance.
ps. I will create a basic app of what I am talking and upload if that would be helpful
The ViewPager may be more appropriate for what you are trying to do.