Best way to display information to a ListFragment? - android

I am creating an app for my campus news paper and one of the features will be a tab with a list of all the clubs and organizations on campus. I am wondering what the best way to do this would be. I currently use an RSS handler to fetch new articles from the website in another tab, but the information on the clubs and organizations is not on an RSS feed anywhere.
I am wondering what the best way to put this information into a list would be? I initially thought the simplest way would be with a text file, or by xml file. Ideally I would like for the list item to show the club's short name and the full name under it, like I have the article name and pub date in the articles tab. Such as IEEE and under it Institute of Electrical and Electronic Engineers.
When a list item is clicked I want to launch a detail view with the clubs logo and a description. I would like to know if anyone has done something like this before and knows the best way to do this.
I think it would be possible to create my own XML file and parse it like I already did for the news articles, but I am not sure, any advice would be appreciated.

I decided to create my own XML file and read it from the assets folder, pretty much the same method I used for the RSS feed but with a different InputSource.

Related

Asking for advice of how to appraoch an application

as part of a university project, i have to build an android app that will contain informations about diseases, the diseases will be listed in a list (alphabetic order), when clicked on a disease you'll be directed to another layout that contains informations about the disease chosen (including text and images).
i'm new to this and i don't know how to approach this app..and for the text should i build a database or directly input the text inside the app or something like that .if you know a tutorial or something that would help please share
Ps: there is almost 60 Diseases and each disease will have a subitems (causes, treatment, clinical signs .)
thanks
First of all, the comments are right. Please be more precise in your question. Ask what specific problem occured, if possible provide code samples, errors and research state. https://stackoverflow.com/questions/how-to-ask
UI Design (List)
there is almost 60 Diseases and each disease will have a subitems
Therefore I would suggest an ExpandableListView.
Check out this code sample: https://www.journaldev.com/9942/android-expandablelistview-example-tutorial
Afterwards if the user clicks on an item, you open another Activity with details
Data Storage
should i build a database or directly input the text inside the app or
something like that
Static approach
As you can think of, putting data directly into views makes it difficult to maintain, but is faster implemented and less difficult.
Implemenation: I would suggest putting the data into res/raw as a .json file. In your code, build a JSONObject out of it and pass it to the ListViewAdapter.
Dynamic approach
You need Internet permission, a webserver and a remote database from where you can query the data.
Implementation: If you have a hosted webserver you probably have PHP and MySQL databases. Create a table, fill it with data and build an API in PHP where you provide the data from the database. If you have a VPS or dedicated server you can use MongoDB which works with JSON out of the box.
My guess
For an university project, use static. Otherwise dynamic of course.
Hope this helps

Android, Store large amount of text (HTML) and search through them

I am making a framework in order to easily "appify" books.
This framework will need to automatically detect chapter and heading to make a table of contents. The idea is to also be able to easily search through the text and find what you are looking for.
Now what I still need to figure out is:
how to store the data in such a way that I can easily detect the chapters and heading
and still be able to search through the text.
The text that is stored needs to be formatted, so I thought I would store them as HTML or Markdown (which will be translated to HTML). I don't think it would be very searchable if the text is in HTML.
P.S. it does not have to be HTML if there are other more efficient ways to format the text.
Do you really want to do such thing on the device itself?
I can suggest you to use separate sqlite database for every book. With separate tables for table of contents, chapters, summarized keywords of chapters(for faster search) and other service info.
Also here you can find full text search example
Also I recommend you to bring your own sqlite build with your app.
Now lets talk about the main problem of yours - the book scraping.
I have no competency here, I believe this problem is the same as the web sites scraping.
Upd:
Please do not store book contents as HTML, you can store it as markdown for example, it takes less amount of storage, easier to sanitize and you can always apply your styles later

Getting rss topics for arabic sites Dynamically

I want to create an android App that getting Arabic news by RSS Feeds.
I want to know if there are any way to dynamically get the Rss feeds and separate them according to its topics?
Thanks for Advance.
There are at least two ways of doing this.
The first way is to look for a source that provide you with different topics, here's an example of what I mean. With those different topics being treated as each individual news feed, you are able to display them separately.
The second way is to not directly display the feed using ListView. You should first, store the news feeds into somewhere for pre-processing, for instance, you can use SQLite. While storing each news, you include a new column for your desired 'grouping' for separation. After that, you can create an adapter that pull news from this source (or SQLite) and display them in your ListView.
Pardon me for only providing you with the concepts, as I don't have a sample code to show you. I hope you understand what I am trying to describe to you.

Android Application - Multiple Pages with Static Content

I am looking to create an app that has about 50 pages of static content. I can give an example of what it would look like, so that it will be easy to understand the questions.
Imagine a Jokes app, with tens or hundreds of pages
The user can see a full list of jokes, which shows the headings in a list view
Selecting a joke subject will take them to the joke page
From there they can go 'Next' or 'Previous'
They should also be able to favorite a joke
Going to the Favorites pages, will list the favorites for them
The joke pages are static. I could add more jokes with an app update but there is no dynamic content. So I am planning to have any server side code that the app can call.
Now the questions:
In Android, can I achieve this with a single activity (for the joke display) and switch the content based on selection?
There are several to store the jokes - sqlite, separate html pages or just strings.xml. Which is better for these use cases?
If there are multiple headings within a single joke (i.e. formatting as bold for them to stand out), I need to store the formatting along with the content. So HTML looks like the option?
This may be out of scope, but I want to capture the content in a standard way so that if I build an iOS app for this, I can just worry about the UI part and use the same content. Again HTML is the option?
Thanks for looking.
Yes you can achieve this with a single activity.
This is really up to you but Android provides support for SQL Databases. You may also consider looking into content providers.
Note: I would not use strings.xml because you can't load new jokes into strings.xml. If you are getting your jokes dynamically from a website, then you really should either load your content into a database and have the app display from the database, or else just load each html page individually. The html page will be easier as you will basically just be making a browser app, but the database will certainly be faster and cleaner.
HTML is certainly an option, though this question seems a little bit vague. It really depends on how you want to get your jokes. If you want to grab them as HTML pages and just display them, then the work is done for you. If you want to parse through them and display them as an android specific app, then it will be more work but you have more control on the app side.
Yes if you want your app to work cross platform you can use HTML to standardize your view across multiple devices.

Is a listview with webview items appropriate for a news app?

I am building an app that scrapes a certain web site and presents the latest news in a listview, html formattted with an image, a title and a summary. When the user clicks on a row, the news article is showed. It works a bit like the CNet app and similar news apps.
I have no problems with the scraping part, but I am in doubt on how to manage the summary list.
My initial idea is to have a listview where each item is a webview. The listview is populated by a custom ArrayAdapter filled with the scraped html content. Each screen will show the summaries from the 30 most recent articles, ie. up to a month old.
Is this approach recommended or will 30 webviews take up too many system resources?
Would it actually be better to use on big webview, using simple html (ul) to show the summary list?
Also, is an array adaptor the right way to go, or would a cursor be better?
If there are completely different ways to do this, please let me know!
Thanks.
Webview is not a bad approach, but there are better ways. I'd suggest to show the text normally (I mean, in a TextView). I'd use WebView if you are going to show long HTML content that has a complex format or use CSS... but, what you want is showing a preview, so keep it simple. It will be also faster, and more maintainable if you do it in a TextView.
With regards to the adapter... it really depends on how are you persisting the data. If you are just fetching those feeds from internet, parsing them and showing them right away, then you have no choice but using an ArrayAdapter or something like that. On the other hand, if you are persisting your data into a Sqlite database, then CursorAdapter is much better.
Romain Guy, the developer on the Android team who is most vocal on the web helping developers actually said in one of his talks (which you can find on YouTube...not sure which one) that technically you "could" do that, but he'd be extremely upset with you if you did. lol
There is probably too much going on in a WebView to make this the ideal choice of ListView items. I would create a "model" object representing the data for each item that you're abstracting and just make an xml layout that you can populate in a custom adapter.
This video is GREAT info if you're working with ListView
http://www.youtube.com/watch?v=wDBM6wVEO70
I don't see why the application wouldn't be able to handle the 30 html feeds, so you should be good there.
A ListView should be fine to use. Obviously, this all depends on how you want the UI to look and feel.
Lastly, a cursor adapter is used when using a cursor from a db query. Unless you're storing the feeds in a local db, this doesn't seem to be what you're doing. So, the array adapter should work fine for you.

Categories

Resources