• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Custom Android ListView

Hello all, I am wanting to change my listView from the normal ArrayAdapter<String> (simple_list_item_1) to something more like this:

Name ...............................20/25(aligned center right)
Date Created

So There's 3 Views...

1. name
2. date
3. score

I've looked up how to make custom adapters and layouts but they are all very confusing. I just want a simple fix that I can add to an existing project.

Here's my code for my list right now:
//update listView
listAdapter = new ArrayAdapter<String>(GradesActivity.this, android.R.layout.simple_list_item_1, names);
mListView.setAdapter(listAdapter);

Help is appreciated!
 
Hi,
There are a few fixes you need to do to your project. In android app development, listview is the most basic view of all. WHat your are doing here is just passing names into an array. Firstly, you need to create a class that extends base adapter. Then override all the methods and create a constructor of that class that will initialize all the list items. Create a class that contains your 3 variables name, date and score instead of just passing these elements as parameters of an array. Get and set methods will then be needed to be created to save the objects of the class and then set these variables in getview. GetView will thus fetch the required items and show them accordingly. Hope this helps.
 
Back
Top Bottom