Create menu in main layout like in action bar - java

I want to know is it possible to create menu like this?

Most likely, your screenshot is of an ExpandableListView, or possibly a RecyclerView that uses a library to add expandable contents.

Yes, and it's called Expandable List View.

Related

How I can add buttons to the Action Bar?

I want to add buttons to my action bar. How I can do this?
You'd better start with some search and if could not find any answer then ask your question!
By the way:
create an android resource file and name it something like menu_buttons.xml.
Then inflate it and assign to a View object in onCreate method and use it in your ActionBar like:
View v = LayoutInflater.from(yourContext).inflate(R.layout.menu_buttons, null);
getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
getSupportActionBar().setCustomView(v);
http://www.androidhive.info/2013/11/android-working-with-action-bar/ Refer this link... It explains everything from scratch and you have everything you need to know like adding menu items on action bar... handling click events and what code to add where.. So pls go through this

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.

Adding Heavy UI in in each ListView Item

I am bit more concern of OOM on having a heavy UI on each item of a listview, example I have 100 items.
Below is the image that I wanted to practice and copy the UI layout. What would be the possible layout or how can I implement this type of UI. Each items are scrollable until the bottom, with separate contents but same layout. Please see my update below.
Update: I am planning to use card ListVIew, please guide me.
You can use simple listView or card ListView but make sure listView raw does not have many nested layout for avoiding nested hierarchy you should use Relative Layout in list raw
I think using a listview with custom row layout will be better for your app.This will help you to reuse the same layouts which are inflated when loading listview.Also please check the size of images you used in the rows.

Clicking on a ListView

I have a ListView with a header and a footer. I added two items with a class of my own extending the ArrayAdapter class. In this extended class, I have overridden the getView function because I want Views which are not TextViews to appear in my ListView.
On this ListView, I have set an onClickListener.
The problem is that this onClickListener is started when I click either on the header or on the footer, but never when I click on my items.
Of course, the View returned by getView is set to be clickable.
What am I missing?
Do you want to do something different when each list element is clicked? If so, you should programmatically set an onClickListener for each of those 2 elements added. Can you post your code?
It sounds like you are making this much more complicated than necessary. You can create your own layout for each row of a ListView using an XML file. This allows you to use any combinations of Views that you wish. To control what happens when the user clicks on a row in the ListView, your activity class should extend ListActivity and override onItemClickListener(). Alternatively, you can call setOnItemClickListener() on your ListView. For more details, I suggest that you read the Android ListView Developer Guide.
The solution I found : the click listener attached to the 'ListView' is only used for the clicks on the header and the footer. For my custom rows, in my ArrayAdapter's 'getView' function, I attached one listener to the 'TextView' and another to the 'ImageButton'.

Creating a Static Menu Bar

What I've been trying to do is create a menu that stays "static" no matter what activity or layout is being showed. Is there any way to do this, or anything similar to this??
Thanks!
Yes,
1- Create a custom Activity (extend it from Activity)
2- Write the code for menu creation in that custom Activty.
3- Now extend all your Activities from this custom Activity.

Categories