I want to create ListView with 2 columns, something like this:
So I want on different onItemClick for item1 and item2. I can create this layout with custom adapter, but when i click on first row I get InItemClik for whole row. Can someone tell me how can I do this, or give me some useful links....
IMPORTANT:
This is old question, nowadays this type of layout should be created with RecycleView and LinearLayoutManager for one column only or GridLayoutManager for more columns.
add two LinearLayouts(for example) in your custom list xml file and insted of setting OnItemclik listener to list set onClilkListener to these layouts seperately for each.
It should work for you
Use GridView instead of ListView and set it to 2 columns.
Related
I have a single array like ABCD and I want to display it in two columns using ListView like
A B
C D
onClick event should return the position in the array.
Rather avoid to use 2 separate ListView.
Can someone point me to the right direction?
Instead of ListView you can use GridView with maximum columns 2.
set the ArrayList using Adapter.
You should use RecyclerView because it support Grid Functionality which you want to achieve using GridLayoutManager
I wanted to know that is there any way to have multiple HeaderViews for a ListView or on the other hand i want to implement a ListView with three static rows at top and other rows with an adapter which will loaded from AsyncTask,according to ListView recycling i can't make three first row static by using position in getView() function of my adapter body. is there any suggestion to this issue?
If your data is static and always visible, then just put it outside of your listview, above it. And you should have the effect you need.
I used this Library it was useful for implementing Multiple Header ListView, if the first three rows are static then you can add them statically first above the ListView then set the adapter for the ListView and in this case you don't need to use the library
Wrap three views inside a layout (For example a vertical LinearLayout), and add that layout as the list header.
After reading Dynamically add elements to a listView Android , I understand clearly how to dynamically add row elements to a listView.
However, I have one idea that how to dynamically add column elements to a listview.
For example, there are 2 columns originally. After I click a button, I would like to add one one more column.
Can anyone provide example code?
Thank for all sharing.
Just add rows dynamically, but make a custom view with two different elements... So there'll be two elements on your every view of row. And first, set first items while seconds are invisible and after clicking button set others... So it'll seem that you're adding column...
hi I want to use a listview (probably) is it possible to fill each entry with say two buttons two text areas, and have them laid out with realtive or linear layouts?
I have used a scroll view with layout inflator to achieve this at the moment, but I'm thinking listview would be better maybe?
yes you can. you need to use a custom list view for that. making an activity by adding a listview in it and then referencing another xml to that listview using an AAdapter so that every element of the listview has the layout of the second xml file. this tutorial should help you understand the idea.
Yes you can place any widgets for the particular List Item for your listview.
For defining that kind of ListView, you have to define a custom adapter, follow the below steps:
Define a one row file for the list item, say for example, RelativeLayout with 2-3 TextViews.
Define a class by extending BaseAdapter.
Inflate the XML and do display operations inside the getView() method of this class.
Set this adapter to the ListView.
I am currently trying to create a tablet optimized version of my app. However, difficulties occur when i try to populate the screen with a listview that consist of THREE item columns.
Heres a brief illustration:
What is the best way to do this?
UPDATE
The problem is dont know how to setup a listview with 3 columns. In my phone version app, i use a simple listview where each item when clicked opens another activity. How to achieve such for 3 columns?
i think Grid view can be used in your case. Even it is a custom view you can still inflate layout and apply it for single item.
You can use LayoutInflater and inflate a sublayout from xml to create a multicolumn listview. Have a look at Multi Column ListView and this