Custom ListView open another custom ListView - java

I'm trying to create app(workout plan) which use a lot of listView.
It means: When I click "Create Exercise" -> new name of exercise is created in listView. One ListView for every names of exercises. ( I have this ).
But when I click on every item of this listView I want to create new series for each item. But when I click "Create new series" in first item and when I click the same but in a second item it's created in one listView.
But I would like to save this to another listView for every item.
Is it possible? As I think at now, every item should have own listView.
Actually, my question is: Why are every series created in one ListView?
Because the is one common activity for create series?
Could someone help me to find a solution for my case?
In this photo I show my idea.

No need to create a new list view for each and every item.I recommend you to create a table in your db and retrieve items on your need and populate the list view on item click of your list view.

You can use below links as a references to create Custom List view as you have mentioned in your question:
http://www.pcsalt.com/android/listview-using-baseadapter-android/
http://theopentutorials.com/tutorials/android/listview/android-custom-listview-with-image-and-text-using-baseadapter/
first, you have to create an activity in that activity create one custom listview and in your custom adapter- register click listener like "convertView.setOnClickListener(...){...} in getView(...) method.
In that click listener you have to open another activity and put some value you needed in putExtra(..) like startActivity(new Intent(getApplicatonContext(),AnotherActivity.class).putExtra("tag","value"));
And in second activity you have to get that value using getIntent().getStringExtra("tag");
After that create another custom listview based on that value..
Hope this help you

Related

Update RecyclerView From Different Tab In Viewpager

I have a ViewPager with 2 tabs. Each tab just holds a Fragment with a RecyclerView. The RecyclerView in the first tab holds a list of all Articles while the RecyclerView in the second tab only holds the list of user's favorite Articles. Each Article in the first tab has a button in the RecyclerView row that allows the user to favorite it. I want new favorites to be displayed automatically (without forcing the user to manually press the refresh button) when the user navigates to the second tab. How can I go about doing this? Essentially I need to add / remove items from the RecyclerView which contains the favorites, but from the first fragment.
Things I have tried
Call adapter.notifyDataSetChanged() in the onRefresh() method of the favorites fragment. This works, but the performance hit is big because notifyDataSetChanged() is not a cheap operation. I would like to avoid this if possible.
Tried following this guide, and implemented some interfaces. The problem is, when I try to reference the adapter in my fragment from the containing activity, the adapter is always null. I can post code if needed to show what I was doing if this is supposed to be possible.
Now I am considering using SQLite DB to store changes (favorite removals/additions) in the onClickListeners, and then checking that table in the onResume() method and processing the changes individually, one by one with notifyItemChanged()
Is there a better way to do this?
For SQlite use CursorLoader to load data from SQlite. You can register to be notified when a data changed in a table. Then your loader will automatically load data again. Check this answer. Also check this Thread.
For getting data from internet you can use
Communicate with 2 fragments via parent Activity. Check this and this answer. This tutorial is good for better understanding.
LocalBroadcastManager to notify from one fragment to another fragment.

"Nested" RecyclerViews

Hi everyone.
I've come up with an idea for an Android App, and I was thinking how to turn my thoughts into something working. I know how to program for Android even though I'm not that advanced as you might see, so I wanted some tips from you guys who I'm sure will be able to help.
Idea
I was thinking about an App to organize stuff, see your objects on a list and be able to add, move or remove them from the list.
Thoughts
I first thought I needed a RecyclerViewto display each item. Then I thought every item itself might be a box, and so be containing other items inside: this brought me to think of a sort of "nested" system of RecyclerViews. Before going too deep into this system I had to clarify each item should have been a Class, each of which should have had a RecyclerView assigned.
Question
I was wondering how I could make this "nested" system of RecyclerViews. I thought about making a RecyclerView an object, because I need each RecyclerView to display, function and be always the same in any screen of any item. But I don't know what the best way is.
Should I make it an object? How do I create a new RecyclerView through a button so the user can first tap an item and then, eventually, tap a button (inside the item details view for instance) to make it a box item and so create and open a RecyclerView when tapped?
P.S.
It may seem like multiple questions but it actually is only one: how to add and display a RecycerView when I tap a button inside a details screen of an item, of course automatically (have a reference to that RecyclerView).
You have to create the RecyclerView that holds your items list, let's call it rv_list, this RecyclerView has an adapter that takes each item and adapts it to an xml layout row_item.xml that you should define. Now to make an item itself display its own recyclerview you should put a recyclerview inside row_item.xml and populate it when adapting that item to rv_list inside the method onBindViewHolder.

Array list adapter with button objects

I am new to android app development.i want to create a list view that has only one button per cell of list view.For the adapter of this list view i need to give 'ArrayList' as parameter so that I can add and update list view whenever I need.
Take a look at this tutorial for custom listView.
You can put the button or anything you want in rowlayout.xml

AutoCompleteTextView unselectable drop down items

I have created a new application with Scrollable Tabs + Swipe, I start with the auto-generated code.
The activity extends FragmentActivity so I'm obviously using Fragment in my project
The user taps an item in the menu which takes the user to another tab, like so
mViewPager.setCurrentItem(SectionsPagerAdapter.FRAGMENT_INDEX, true);
This tab isn't visible until the user selects the menu item
A new Fragment is instantiated, with the appropriate layout file, which, currently, just contains an AutoCompleteTextView and a RelativeLayout. This is how I set up the ArrayAdapter:
arrayAdapter = new ArrayAdapter<String>(context, R.layout.fragment_layout, R.id.auto_complete_text_view, arrayData);
and then set the adapter on the AutoCompleteTextView.
Everything works fine, I get the suggestions in the drop down, but the problem I am currently facing is that when I tap the drop down item, nothing happens. The AutoCompleteTextView doesn't get populated with the selected drop down item.
I noticed that the when I select the drop down item I get the "blinking line".
I have tried creating my own AutoCompleteTextView and using different contexts, but I am getting the same results
Any help is much appreciated.
Ahaha, OK, so my mistake was when I was setting up the ArrayAdapter I was using the layout ID of my fragment, but I changed it to android.R.layout.simple_dropdown_item_1line and is now working perfectly fine =]]

Is it possible to make a dynamic mix of ListView and TextView?

I tried to found a method, but no results. I want a ListView like below, and when I click on an element, like "Word", it'll be like this picture :
Is it possible ?
What you described is what an ExpandableListView does.
Basically it's like a listview so you'll still have to create your own adapter, but it lets you click a row to inflate a bigger item that you can then stuff your text into.
I would recommend creating your own class that extends ArrayAdapter or BaseAdapter. Then you can make use of the getView() method that gets called every time the screen gets redrawn for the user. You can then design multiple views for each selection and choose which one to display in the getView() function. So when the user selects an item, you set a flag in your custom class, and then notifyDataSetChanged() and you're good to go!

Categories

Resources