How to implement a endless ViewPager? - java

My app
My App shows a ListView with CheckBoxes in each row. The CheckBoxes are saved for each day. Buttons are used to navigate between the different days.
The Problem
I want a slideable TabView instead. I tried to use ViewPager, but I donĀ“t know how to implement it the right way. The problem is that I need tabs for the days between year 2000 and now. How can I achieve this?
This is how the app should look like

Related

How to update content of the activity without creating new Activity?

I'm trying to make an app and I have made a blueprint for a specific activity, but I don't know how to implement it. The layout contains few buttons at the top of the activity, and each button features some information, which is displayed inside the view. The view which needs to be updated is present under the buttons. I don't want the activity to be changed, instead it should update the contents of the View, which is different for each category/button.
By doing some research I have realised that the "Tab Layout" can be used to achieve my requirements, but I don't want the tabs and I need some stylish buttons as a replacement.
I know I'm not the best at describing, so I have looked upon Dribble and found one design which is 100% similar to blueprint.
I want to achieve this using XML and Java using Android Studio! Every suggestion will be a great support foy my app.
Thanks a lot.
As far as I know, you could achieve that by using fragments (which is the same concept you would have used on TabLayout). I don't really know how much knowleadge you have on Android, but if you know what a Fragment is, it should be easy for you to recreate the idea.
You have 3 buttons for 3 different fragments, so you must design every fragment by separate and change it depending the button you click.

Is there a way to create pages/activities or something similar based on a users input?

I want to ask a user how many times a week they go to the gym, and depending on their input i want to display "x" amount of activites one after the other.
Example: User inputs 4 days a week. following that, the next activity will be a page for day one, then they click a button, then day 2, then click a button, then day 3 and so on.
One way I thought of doing this is creating 7 activities for the 7 days of the week, but id like to find a better way.
Another way which I'm not sure if its possible, is to create a sort of recursive Activity.
Example: User inputs 4 days a week. following that, the next activity will be a page for day one, then they click a button which opens up the same activity but with all the data they put in previously saved in a DB, and the inputs for day 1 has been cleared, so it becomes day 2.
if any one has any knowledge on the above scenario if you have done something similar or know if android studio has a better way to do this, any input will be appreciated, still a beginner using android studio, Thanks in advance.
Can't you create just different views in Android Studio ? Creating 7 different views would be the easy way, but if you want to do it more elegantly you could create one "template view". So you create a file/view with some placeholders like "Activity" and "Day_X". Then for every page the user can get to, you open up the same view (page, mask) but fill it with different data.
Then you can just based on the user input code something like:
"Create me NUM_DAYS_USER_INPUT times the activity template mask", once with the data for activity one, once with the data for activity too and so on...
You just need to pass the correct data for the single views to the masks.

How to increase the height of list row using fragments?

I am working with fragments and created simple basis list and everything is working fine. But there is one thing that I can't do my self. I want to increase the height of the each row to cover the most of screen of any device. I know how to do in activities but I am not familiar with fragments. Any one can find a way for me?

Performance Issues while building custom DatePicker

for my project I need to build an own, custom DatePicker. I can't just use the standard DatePicker, because I need features like selecting multiple dates, disabling special dates, etc.
I planned to build my own custom DatePicker as close to the standard DatePicker as possible.
Therefore I have decided to use a ViewPager in which I nest a custom View that holds a custom ViewHolder containing just a TextView to Display the current Month and a RecyclerView to Display the Actual Days of the month in question.
The result looks something like that:
I don't think it is necessary to provide the whole code (adapters, layouts etc.) because the whole thing is fairly straight forward but if you need to see, I can add it after the fact.
Now to my problem: When I start the activity, the whole application stops for about 3 seconds, and I get the following logcat-output:
I/Choreographer: Skipped 111 frames! The application may be doing too much work on its main thread.
I narrowed the problem down to the RecyclerViews.
(when they are deactivated, there is no freezing/stuttering whatsoever)
When the activity starts, the application has to load 3 full Recyclerviews (because I set viewPager.setOffscreenPageLimit(2); )
and that initial loading causes the whole application to freeze for a short amount of time. After everything is loaded, the whole thing works completely lag-free.
To this problem I have 2 different solutions in mind:
Load the RecyclerViews in another Thread
The idea is, that the activity starts, and the RecyclerViews are only shown, when they are loaded. This wouldn't be perfect, but at least the activity would start without causing the whole application to freeze.
Substitute the RecyclerViews with something better performing.
Is there even a View/Structure that a) enables me to display a gridlike Structure and b) is better performing than a recyclerview?
Initially I chose the RecyclerView for displaying the days, because I thought that the Standard DatePicker uses it too, but after some digging in the integrated classes I am no longer so sure about this.
To me it seemed like the days are drawn without any View whatsoever. (I could be wrong about that)
Is there any possiblity, that one of those ideas could be working?
And if not, is there another way to fix the performance-issue?
Thanks in advance

View different images depending on what item in my list view I click

I'm fairly new to Android programming and I've got this project I need to finish and I'm currently stuck.
I've got a standard listview in a Menu class with an array containing around 20 different elements. So what I want to do is load images in an imageview depending on which item in the listview I click, and since I'm a beginner the only idea I had was to make a new activity for each imageview which seems like a pretty bad way to do it since I'd need about 20-30 new activities..
To sum things up what I want is:
Code for making ONE activity that will display a different image depending on which item in the listview I click, probably pretty basic coding I want as simple solution as possible.
If possible I'm also looking for a solution that includes an SQLite database that stores the URL of an image and then display it in a single activity, also depending on which item I press in my current listview.
(I hope you understand my needs, and if you need I can also post my current code for the Menu class if it helps you help me) Or you can just show me a different way to make this work, I appreciate every answer! Thanks in advance!
NOTE
And please keep in mind, I'm a noob at Java and Android so keep it rather simple or at least explain what you do.
When you click on a list item, display the image in another view in the same layout, unless you want the image to take up the entire screen real estate. If you want it in the entire screen, go to a new Activity by sending the activity an Intent.
Activities are the "controller" of your application. They interact with the visible UI and the input from the user. You don't need a separate activity for each image, just an activity that's associated with a "place" in the UI (an ImageView) where you'll display the image.
I'd start by adding the images as resources under res/drawable before going on to databases.
You are going to have to do most of this yourself. There really isn't any substitute for taking the time to learn Java and Android. There are several tutorials and Android University classes under the Resources tab in the Developers Guide; I suggest you do all of them.

Categories