Android swipeable text view - android

I am trying to create a app where you would get a list of strings and you are able to swipe through them. What I had in mind is to have a text view and every time you swipe the text is changed to the next element in the list.
But I am under the impression that this might not be the best way to do things. Is there any other way I could do this ?

Related

Access Adapter items of Recyclerview

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.

Which is the better method in Android for creating a dynamic list?

If you are creating a very dynamic list, say, where every row can have a different set of input types plus optional buttons, and the list length is based on another dynamic value, is it better to do this in a list adapter or creating a custom view in a scroll window?
After struggling with list adapters for quite a while now something finally occurred to me- this seems dumb. It seems like I am going through a lot of work keeping track of what spinner is set to what value, which row was clicked and so forth.
For example, say you are showing something like a contacts screen with various details that can be entered about a contact. Some rows will have text inputs (name, address etc), some will have spinners (ie. state, group), some will have checkboxes (like 'favorite' or something). Also, there is an 'add' button that allows you to add another field to edit. Is it worth making this in a list adapter or is it better to populate a custom view, and if the "add" button is clicked, we re-create the custom view, adding a view of the type they want to add?
I hope this is clear.
ListViews (and List Adapters) are meant for data that is to be displayed in mainly similar views. For your example, it is much easier and more natural to have a predefined layout file with the screen and use view visibility so select which views are to be shown. If you need to add views to the screen you can do this dynamically by using findViewById on the layout and then using it's addView method.
Let me know if you need more clarification or sample code...

TextView is not Clickable on OpenGl Curl View Effect

In my application I have requirement like this.I have number of data and I need to show that data on ListView kind of layout,now I have suppose total 6pages on each pages I want to show such data.I have listed number of textview on each page.Suppose i have 7pages so i need to make book kind of layout for that i am using this Code.https://github.com/harism/android_page_curl.
with this i am able to get such effect.As mentioned in below image.
Now my issue is,As OpenGl is converting entire layout to bitmap,i am not able to handle click event of textview.Whenever i click on textview on that time ACTION_DOWN method is called.and offcourse it should be called as entire layout is converting to bitmap thus we can't handle textview click event.
for making solution of this have googled and found some trick from This issue.Here mentioned to make seperate layout for handeling click listener,but not getting what exactly i have to do,as i don't have any experience in OpenGl,so if any one have idea about this issue,any one who can guide me handle click event.
The above solutions depends on your views pages. It may not work if you use ListViews on your pages or any ScrollView, you have to retest your application performance...
What i have done to get it working, is to create an extra root parent with,FrameLayout, place on top the widget, fi.harism.curl.CurlView and add PageContainer(RelativeLayout on may app).
At run time, get the drawable of your view page (View.getDrawingCache()) , and add The real PageView(witch contains click listener) to the PageContainer. Make the PageContainer alpha to 0. You have a duplicate page (transclude) to receive the page clic, the CurlView will still handle touch events for curl.

Change content of view on swipe

I'm making an android app that will essentially show the user a word, definition and example for each element in the database. It's sort of like a dictionary. I have already made it so that all the words, along with their definitions and examples, have been entered into the database but now I am trying to figure out a way to display them.
What I would like is to have 3 textviews which would contain the word, definition and example respectively in a view and every time the user swipes down to go to the next word entry in the database. Every time the user swipes back I'd like the view to repopulate the textviews with the previous entry in the database.
What I'm wondering is what is the best way to do this? Is this there a particular class that deals specifically with this type of thing? Bear in mind that I don't want to switch views since I would have to make over 300 views but rather just repopulate the values of the textviews with the new values from the database. Bonus points if it's easy to make a flip/slide animation with each swipe but it's not really necessary.
You can use 'onFling' method. You can detect the swipe direction and with a listener for the right direction swipe, you can call your methods for the data source.
here is an example : How to detect swipe direction between left/right and up/down

Image in a custom List Android

I have created a custom adapter to display a list, there is an image that is displayed in each row ( the image is the same for all rows, except using an array i am assigning it different values depending on the position). An xml file defines the relative layout that i am using. My problem is that i can either get the entire row to be clickable or nothing at all, I only want this image to be clickable, instead of the entire row. How would i be able to do this ? i am new to android and am pretty much following different tutorials trying to create my list. Any help would be appreciated.
layout is like this :
TEXT:
[Image]
TEXT:
thats wat a row looks like...getting two texts from two different arrays and shows it, a third array is used to link to the image. I just want this image to be clickable instead of the entire row.
Thanks
Android's list component manages clicks per row. This makes it very difficult to achieve what you want to do. Two solutions come into mind:
1) If your list is never very long you could simply use linear layout and scroll view to build the list. This approach won't work if you fill in the list dynamically and you can't be sure that there won't be a very large number of rows as it would use too much memory in that case.
2) Other option is to use ListView but make your text components and images different view types in list ie. break you row into three.
That can be achieved overriding list adapter's getItemViewType(int)
http://developer.android.com/reference/android/widget/Adapter.html#getItemViewType(int)
In this approach you can make the image rows clickable but the text rows not.

Categories

Resources