How create Activity with a few ListView? - java

I have to create Activity with ListView, when I click on item on ListView item and if this item has more items, new List sliding from left side to half of screen and so on...
It should be kind of this
http://a1.mzstatic.com/us/r30/Purple6/v4/d5/92/2a/d5922a96-fccf-508a-52fb-c3a21a8d8d4c/screen480x480.jpeg
Does somebody have some idea?
I don't need code just show me direction, but if you provide some simple example I will be glad to see it:)
Thank you

http://www.vogella.com/tutorials/AndroidListView/article.html
This link has an implementation of how to make a listView. You would have 2 different activites with two listViews. And while implementing the onitemclick method of one listView you will have to set up an intent which will open the second listView activity. Did that gelp?
Even I am new to android so I hope that logic helped. I cannot explain without a code.

Related

using The same RecyclerView for two Tabs in android

I have a RecyclerView and two Tabs in my MainActivity. I just want to show another data in RecyclerView when each Tab gets selected. for doing this should I use ViewPager for Tabs? should I use Fragment? I really don't know. Are they needed in my example? the only difference between tabs is just the data they show to user inside RecylerView. RecyerView is the same. Toolbar is the same , etc. Can anyone help me? Thanks
First off yes you will need a ViewPager. This ViewPager will require you to use Fragments. Take a look at this example from the official docs.
To solve your RecyclerView problem you have two options:
define a custom RecyclerView (by extending Androids RecyclerView)
defining a custom RecyclerViewAdapter and use it with a RecyclerView
I would advise you to do the first if the RecyclerViews are completely similar. Then you could define all your properties with it, without having to do that twice in your Tab Fragment. Otherwise take the second option.
Have you looked at using Conductor?
Conductor
Why I choose Conductor over Fragment?
It is a cool replacement for Fragments.

What are the general instructions to add a new fragment that uses a new screen and has its own layout?

I'm struggling to figure out how to create fragments that have their own layout files and take up the whole screen, as opposed to adding them to the activity's layout.
For instance, in my activity there is a button which should call a RecyclerView Fragment that takes up the whole screen, let the user pick an item, and then return to the activity. All the examples I'm finding though use transactions to add or replace on the activity's layout. How do I make fragments that are inflated from their own layout files and call them from the activity?
And sorry, I'm sure there's a better way to ask but I'm just going through docs and vids trying to learn.
A few line difference between Fragment and Activity:
An Activity is an application component that provides a screen, with which users can interact in order to do something. More details: http://developer.android.com/guide/components/activities.html
Whereas a Fragment represents a behavior or a portion of user interface in an Activity. http://developer.android.com/guide/components/fragments.html

ListView inside ListView item

I want to ask one question, should I use ListView inside ListView item? Or I should redesign and remake my idea?
Example of ListView, but should be with couple sub items:
A ListView inside a ListView item is never a good idea. If you want sublists inside your list you can, for example, use a ExpandableListView. However, with the migration from ListViews to RecyclerViews I would recommend you go and implement this instead.
A ListView will never work correctly embedded as an item in another ListView. In fact, scrolling things inside other scrolling things is almost never what you really want to do, as it would be confusing to the user how to actually navigate your screen.

java android view structure

Just a simple maybe stupid question.
Is it ok to use multiple activities at once in an android application using an Inflater? I want to have multiple views on my screen without losing the previous view. For example, a user clicks on a button and a information screen shows up. Start Intent would convert the whole screen to the information screen activity.
Using an Inflater works but I'm just wondering if its the right way to display multiple views. Thanks in advance.
You should be using Fragments for this. Each fragment has a view/layout and you can move them in & out of your main view as you require. There are many tutorials
You can set the visibility of the views, e.g.:
Button b = (Button)findViewById(R.id.button);
b.setVisibility(View.GONE);

Android ListView - onListItemClick does not work properly

I created a ListView in Android, and a corresponding ListActivity. Each individual item in the ListView has just one TextView (I plan to add an image and a CheckBox later).The ListActivity overrides the onListItemClick to perform certain tasks on click of any item on the list.
Heres whats happening -
When I first tried clicking on any item, nothing happened.
I then tried setting the properties "Focusable" and "Focusable in Touch Mode" to false for the TextView, as mentioned here, here and here. The List items started recognizing clicks, but only when I clicked somewhere away from the TextView. Whenever I tried clicking on the TextView or anywhere near it, it did not work.
I also tried changing various attributes like Clickable, but nothing has worked so far.
Any idea what I could be doing wrong ?
Thanks
After playing around with virtually every attribute in my TextView, I finally found the reason why it was not working. It was because of the attribute android:inputType="text" in my TextView. I'm not sure why I added that piece of code (I probably copied the TextView from one of my other applications), but removing it solves my problem.
Class which will listen clicks on ListView should implement interface AdapterView.OnItemClickListener

Categories