Android - Dynamically load content - java

I have a page in my app where the user can see a news feed (mostly images). How do I display these images (Using a LinearLayout maybe?)? And if so, how do I dynamically increase the size of this scrollable layout as I am scrolling down? (To load more images)

You have to use ListView. From the doc:
A view that shows items in a vertically scrolling list.
you have to provide a ListAdapter to your ListView. Basically the apdater is what fills up the ListView. It is higly customizable. You can simply pass to the adapter your data set or extend the adapter and customize the getView method in order to get the data rapresentation you want.
a tutorial can be found here

Yes you have to use listview, just add the content and notify the adapter.

Related

JavaFx ListView for load Messages in chat application

i wanna write a chat app with a listview for messages item.
it's load messages at top and bottom of listview.
i want when messages added at top and bottom of listview scrollbar doesn't move.
(maybe this is because of javafx doesn't support 'cells of different lengths').
Try check ScrollTo Method tabWiew also ScrollTo Method ListView you just tell witch index should be showed always

What kind of layout and java class should i use for a friend list layout?

I am learning android development and i am kinda stuck here. I want to create a friend list screen like shown in this picture.
What kind of activity should i use? Is there any available resources similar to what i want to achieve?
Thanks!
you can use ListActivity , also check out tutorials on lists, for example:
http://www.androidhive.info/2011/10/android-listview-tutorial/
http://www.vogella.com/tutorials/AndroidListView/article.html
you can find mire tutorials on google.
also you can use a regular Activity class with listView in the layout file
Use list view and custom adapter to populate the list view...
Listview should extend to the bottom but limit it just above the Type a name edit text and button.
Custom list view should contain linear layout horizontal in that include checkbox, Textview and Button
For type a name and Add use linear layout horizontal
Use listView with custom adapter , for array use arrayList<,friends,> sure you have to create friends class, in xml file put ListView then below that button and TextView

add items in Adapter

I'm new in programming.
I have a problem with filling GridView from the Internet.
Through AsyncTask, I parsed much content (img, txt), create and filling database.
And when I call the adapter to GridView (CursorAdapter or any of the standard adapters), he always fully updates all the already-made content.
Please advise some sort of a way to fill the content GridView without changing already completed views, from DB, which actively adds data from the parser.
What adapter and methods, be better to use in this case? I would be very grateful for some guidance or example.
Thank you for taking a few minutes for giving me.
Basically, if you have a reference to your list adapter, you only need to add an item to your adapter, and then call notifyDataSetChanged() on the adapter. This will display the new item in your grid view without needing to add all the items again.

The tags for the GridView items are applying only when they are visible?

I have a GridView which is scrollable: only some of the items will be displayed and only after scrolling down the GridView. We can see the other items. The problem is, I am setting the tags for all the items in the GridView, but by tracing the LogCat I came to know that it is not accepting to set the tags for the non-visible items in the GridView(I mean the items which are inside the grid, but at that time are not on the screen)
Before scrolling:
After scrolling:
Only after scrolling down the other items the tags are applied.
How can I set the tags for all the items of the grid, even if they are on the screen or off the screen?
Your problem is that you set the Tag in the getView method and this method is only called by the framework when the view need to be displayed.
Don't know exactly what you need to do with the view tag, but I think that instead of trying to get the data from a non-displayed view, you must get it from your ImageAdapter (ia.imageid[]).
EDIT:
To answer more preciselly to your question:
How can I set the tags for all the items of the grid, even if they are on the screen or off the screen?
As soon as the view doesn't always exists when it is not displayed: you cannot do it.
I suggest you to explain why you need those tags... may be you can use an alternative solution than view tag to accomplish your final needs.
Anyway, if you really need to have tag on view that aren't displayed yet:
Initialize a view array in onCreate method.
Populate this array with all your views (and set the tag)
modify getView method of your adapter to return the view from your array of view instead of creating the view.
Please note that I don't recommend this solution since it will consume more resources.
Finally myself i got the solution for my question.Thank you for all who gave their valuable suggestions.
Thank you #ben75
i checked the position of present clicked item and then applied the tag so if the user want to select the item which is presently not on the focus he has to scroll the grid and then have to select the item and then only the tag will be applied.

iPhone has UITableView, what does android have

I have an app on the iPhone that is completely table view driven. On android all I see is a static table, how can I create a table that I can populate with data that I requested from the network.
You could use either ListView or GridView. ListView has a method getView which you override to customize ListView item. This very much like (UITableViewCell *)tableView... in iphone, except that you needn't count the height of each cell. If you want to have something like tableView with sections you could use ExpandableListView. Here are links to Android ListView, Android Expandable ListView and Android GridView. There can also be found very useful examples in Android Dev web-site.
You can use GridView or ListView with custom View for row. In both cases you can supply a BaseAdaper (or a subclass of it) through which you can manipulate the data.
If you want the exact grid border like example here you go Android Grid Border... Obviously you can render data dynamically from whatever the source is...

Categories

Resources