My app has a custom segmented control(got it from internet - its really a radio group) and under it a listview. When a user clicks on a row in the list view, a fragment is attached to the activity that displays a different listview. This new listview seems to replace the old one. The problem is that the segmented control is still there, whereas I would like the whole view to be the new list view. Knowing that fragments are embedded in the view group, I thought progammatically removing the segmented control would work, but it didn't, the control just becomes empty space.
It's important that the app works the way I described. I could explain in detail why this is so, if needed.
Any tips? Much appreciated.
Related
I'm using Recyclerview to show a list. I want to delete some items like IOS. In my listview template I have added a button to delete item which is invisible by default. In my activity I have another button attached at bottom (Not part of listview) and on tap of this button I want to make all delete buttons of listview visible.
My Question is how can I get reference to all delete buttons of listview in activity and is it the right way to do this?
Thanks
Assuming you have ViewHolders set up, you already have references to all the buttons in your list. All you have to do is to make them visible for every item in the list with a simple loop.
In case you haven't implemented ViewHolders I suggest you check out the documentation and take a look at some simple tutorials on how to use them.
On a side note. If I understood correctly you're making a bottom tab for your app and since you referenced iOS I gotta say this; Remember that Android and iOS are two unique operating systems with their own ways of handling things. Check out Googles pure Android documentation.
In your question title you say RecyclerView, but in your text you say ListView. The solution is similar either way, but it's best to be perfectly clear what you're doing.
In either case, there are at least two different solutions.
First, you could use a boolean flag to determine if all the the item buttons should be showing or not. You check this flag at the time the item view is inflated or created and toggle the button accordingly. If the boolean flag is ever changed, the easiest thing to do is tell the RecyclerView/ListView that the underlying data has changed and to redraw all the views. Call notifyDatasetChanged on the adapter.
The other thing you can do at the time the item buttons should change is iterate all the visible item views, find the button, and change its visibility. With RecyclerView, you can do this, and with ListView you can do this.
I'm implementing this to android tv box with remote functionality.
I have a LinearLayout in ScrollView containing generated View.
I'm programmatically set the NextFocusUpId for the first View to the last View and vice versa so when user navigate up through the first View, it's rotate to the last View and vice versa.
the problem is when i sort the list with alphabetical order later, the first and last View got place in the middle, and when user navigate up through the list and arrive at the first View (before the sort), it's jump to the last View (before the sort), instead of the View next up to it.
if I set the NextFocusUpId to itself, user cannot navigate through the View before and after the sort of the View.
view1.setNextFocusUpId(view1.getId());
if possible I'd like to avoid to manually iterate the views and add the NextFocusUpId and NextFocusDownId in each view when the sorting is being run.
When this question being made, I found this solution.
view1.setNextFocusUpId(View.NO_ID);
do the reset.
EDIT:
It appear that in the documentation, there is the solution in the documentation
http://developer.android.com/reference/android/view/View.html#setNextFocusDownId%28int%29
Parameters
nextFocusDownId The next focus ID, or NO_ID if the framework should decide automatically.
I am developing an activity with a ListView in which I need to change the current row by another layout by clicking on the row, and I'm not finding any way to do as much as I look (I take hours searching for possible solutions and I have not seen any reference to this problem). I do not know if this can be done in Android, but if anyone has an idea of how to do this would be appreciated.
Thanks in advance.
PS: The ListView control is normal and just want to replace a layout with a different layout. I'm using the API 15.
Use a ViewSwitcher
http://developer.android.com/reference/android/widget/ViewSwitcher.html
A ViewSwitcher is -
ViewAnimator that switches between two views, and has a factory from
which these views are created. You can either use the factory to
create the views, or add them yourself. A ViewSwitcher can only have
two child views, of which only one is shown at a time.
I suggest merging the two layouts in a single one and hide the second one. In your adapter data you should have a flag or something to indicate which layout to display. When you click a row, toggle that flag for the selected item and notifyDataSetChanged() on the adapter. This will make sure the changed layout remains even if you scroll up and down and the row goes off screen.
A more optimized solution is to have different item types in the adapter.
I would like to know some insights or ideas regarding the custom list like view in the new google plus updated android app. I'm specifically researching to know if this was a list view or a scroll view with inflated custom views in it.
P.S this also has a custom entry in animation when user scrolls which is giving me a doubt that this could also be a list view with custom adapter which has an animation when list items are recycled via getView.
Check the screenshot for some clear understanding.
I don't have installed this app, but at least the way how it looks could be implemented with a ListView.
A custom adapter needs to be defined, and that custom adapter will inflate the layout for every entry, in the getView() method.
The layout of every entry, or with other words the layout of each row, could be represented by a RelativeLayout with all its components: The title, the +1 button, the photo, the date, etc.
I am making an application and I can't figure out what's best to do.
I have a long list of tableRows. About 200 of them. They are different
models of a specific product. Each row, when clicked, should show a
screen with that item's specs for the user to read.
Here are my options, I would need help and guidance on how to do each one of these as I am a beginner (but I'm getting more advanced)
First Approach
Create an activity for each and every item. The user will click the row and then they will have to press back to get back to the list. (I know how to do this. I'm fine with this)
Second Approach
I read about horizontal page swiping. Similar to the Play Store. I would prefer this option, but would I be safer sticking to lots of activities?
When the user clicks a row, it would bring them to the item spec and they will be able to swipe left and right between all the items. Pressing back will bring them back to the list.
(This is the one I need full step-by-step guidance with, so I can learn for the future, thanks)
Does anyone have any other suggestions how I would handle this amount of data?
Thanks
You have a long list of items. That suggests you use a ListActivity to show the items. If the items have similarities, use one view to show them and one Activity to show details. If the items are totally different, use different layouts to inflate in getView and different activities. Having the items in one list suggests, however, that there are similarities and it's best to use one layout in the listview and one activity for details.
Alternatively, you can group your items according to similarity in the way you show them. You may end up with ten different views to use in the listview, and ten different activities.