I have very little knowledge of generics other than how to 'use them'. In my app I have various ListView Activity that seem to share similar methods and variables and have the exact 'algorithm' in the sense that the steps performed are all very much the same.
For example in my onCreate method I call a method to add a footer, start a progress dialog, call a method to get content based on a xml url and there is a Handler and Runnable fields that is used to call the method to fill the data for the list when the xml parsing is done.
I was thinking maybe I can create a BaseListActivity that does all these things/has methods to all these things and each specific ListActivity can be extended from that. The problem is they use a List object to hold the items that the xml parsed and which the ListAdapter is backed by.
So here is code of the fields used:
// list of games from xml
private List<Game> mGames = new ArrayList<Game>();
private List<Game> mNewGames = null;
// Need handler for callbacks to the UI thread
private final Handler mHandler = new Handler();
// Create runnable for posting
final Runnable mUpdateResults = new Runnable() {
public void run() {
mGames.addAll(mNewGames);
fillData();
}
};
LayoutInflater mInflater = null;
private ProgressDialog mProgressDialog = null;
private int currentPage = 0;
so really the main difference is that each different activity would use a different object type for the List (ie. Game, Media, Article, etc.). How would I go about doing this?