Listview inside gridview android - android

I want show listview as a grid items how can I?I have tried it but when I call setadapter method for populating data into listview inside gridview's getview method data is not being populated.

i dont understand why you are adding a listview to gridview....this can make your application slow...just take a linear layout with a vertical orientation as item of a gridview..and add required elements dynamically to this linear layout according to the need...it will look same as listview in gridview...but will work with a much better speed...
Let me know if you want more description or a sample code....

Related

Proper way of showing tip on a ListView element

I have a Fragment which contains a ListView. The elements of ListView are RecyclerViews which scroll horizontally. Each element of the RecyclerView is a CardView which contains some elements such as ImageViews and TextViews. I have to display a tip on a TextView inside that CardView.
This tip has to be displayed on the TextView in the first CardView of the first RecyclerView of the ListView. I am using ShowTipsView library to show the tips. What is the correct way of showing this tip?
Should I put some code inside the adapters of the ListView or RecyclerView or could it be done from the Fragment's code itself?
The real problem that I face is, how do I get access to the specific view(TextView) inside my Fragment's code?
I found this from your given link:
ShowTipsView showtips = new ShowTipsBuilder(this)
.setTarget(btn_test)
.setTitle("A magnific button")
.setDescription("This button do nothing so good")
.setDelay(1000)
.build();
showtips.show(this);
I see that setTarget(xxx) accepts a View. So you can do this in your fragment because it has your views.

Alternate for a listview with single row

I have a ImageView with a TextView and Button. I have it currently in a custom list view, but I noticed now that I don't need to show more as one element (object). So I actually don't need a Listview to show the row (list entry). How can I show the list entry without a Listview?
You can put the elements of your custom listview item into a Layout, e.g. LinearLayout and simply add it to your activity's layout where you needed it.
You can set an OnClickListener for that layout, so user can click the whole thing.
I think you should use ListActivity. Then you can set up empty view for list. Here some tutorial: ListActivity and ListView Tips.
Also you can implement that logic with Recycler view by yourself or use library.
Here is solution from stackoverflow

Android listview with horizontal lines when empty

I have a Listview in my Android app, and I want there to be some horizontal lines when the list is empty to indicate to the user that this is a List. I know that there is the setEmptyView method on ListView, but I'm not sure what to put in that view if I want there to be list rows with horizontal lines. How would I accomplish this?
Having a bunch of horizontal lines for an empty list is an iOS convention. If you want your app to fit in with Android better you should set something else. Perhaps notify the user there was an error or that there are no items in the list. You can add this right to your layout.xml file if you're using a ListActivity. All you need to do is create a view and give it the id #android:id/empty.
put the listView in a FrameLayout and add another view in that Frame.
if you having any item in the list hide its (visiblity="gone") and show the other view.
OR
change your adapter to return multi ViewType
in your adapter if you have no item return other type of view

Android: Add cells to GridView dynamically?

I am want to add cells to GridView dynamically when the user reach the last row of cells its like the show more?
Check out CommonsWare EndlessAdapter. Very straight-forward Adapter implementation.
You could also manually use an OnScrollListener on the GridView. Use the onScrollStateChanged() callback to figure out when the grid is OnScrollListener.SCROLL_STATE_IDLE, then determine if the last grid item is visible. If so, get more items for your Adapter, and call notifyDataSetChanged().

How to reference first list item inside ListView?

I would like to add Top Margin on the first item in the ListView. Is that possible?
Or, how can I reference first list item in the List View?
I tried
lv = (ListView)getListView();
View myRowItem = lv.getChildAt(0);
Probably, it doesn't work, because at the moment I executed it, list items didn't exist yet. I assume I should try above code in something like onPostRender event. Is there something like that in Java Android?
You would have to create your own adapter, and put that condition in the getView method. However, I'd like to know why you would want to add top margin just to the first item... wouldn't it behaves the same if you put that top margin to the ListView itself?
In order to get the items, write your code wherever you set the list adapter.
By the way, in order to set the margin, just set android:PaddingTop of the ListView on the layout file (XML file).
The best place to customize ListItems is its Adapter. Create a customized adapter for your ListView and use the getView method to decide what to do with every ListItem. See an example here: How to repaint listview items when changing orientation

Categories

Resources