Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6607343
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:29:36+00:00 2026-05-25T19:29:36+00:00

I want to make a list from some data that I have in my

  • 0

I want to make a list from some data that I have in my database.

The first two sets of data in my database are first name and last name.

I want my list to show both first and last name instead of now where it only shows the first name. How do I do that? My code looks like this:

    private void fillData() 
{
     Cursor contactCursor = mDbHelper.fetchAllReminders();
     startManagingCursor(contactCursor);

     String[] from = new String[]{DbAdapter.KEY_FIRST};

     int[] to = new int[]{R.id.contactlist};

     SimpleCursorAdapter contacts = new SimpleCursorAdapter(this, R.layout.list, contactCursor, from, to);
     setListAdapter(contacts);

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T19:29:36+00:00Added an answer on May 25, 2026 at 7:29 pm

    Here is a full implementation. You will need to create a custom row and a custom Array adapter.
    Here is a full tutorial http://commonsware.com/Android/excerpt.pdf

    This will tell you everything you need to know to get this done.

    Also refer here where ive posted another example.

    How to add an EditText to a ListView

    EDIT: How to build a custom listview and return data from a databse

    You first create a listview activity.

    public class meeting_list extends ListActivity {
    
    
    Cursor model = null;
    meetingAdapter adapter = null;
    
         //This should be what ever your database helper is from your SQLite base.
    meetingHelper helper = null;
    
    @Override
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.meeting_list);
        helper = new meetingHelper(this);
        model = helper.getAll();
        startManagingCursor
        (model);
    
    
    adapter = new meetingAdapter(model);
        setListAdapter(adapter);
        registerForContextMenu(getListView());
    
     //Ondestroy is used to close the database to free up resources
      @Override
    public void onDestroy(){
        super.onDestroy();
    
        helper.close();
    }
    
        @Override
    public void onListItemClick(ListView list, View view, int position, long id){
        Intent i = new Intent(meeting_list.this, meeting_create_edit.class);
    
                //
        i.putExtra(ID_EXTRA, String.valueOf(id));
    
        startActivity(i);
    }
    
    //Here create a class to extend the Cursor Adapter
    class meetingAdapter extends CursorAdapter{
        meetingAdapter(Cursor c){
            super(meeting_list.this, c);
        }
    
    
    
    
    @Override
        public void bindView(View row, Context ctxt, Cursor c) {
    
            meetingHolder holder = (meetingHolder)row.getTag();
            holder.populateFrom(c, helper);
    
        }
    
    
    @Override
        public View newView(Context ctxt, Cursor c, ViewGroup parent) {
            LayoutInflater inflater = getLayoutInflater();
            View row = inflater.inflate(R.layout.mrow, parent, false);
            meetingHolder holder = new meetingHolder(row);
            row.setTag(holder);
            return row;
        }
    }
    
    
    //Here create a class to actually hold the view for the row in the listview.
    static class meetingHolder{
        private TextView mtitle = null;
        private TextView maddress = null;
        private ImageView Icon = null;
    
        meetingHolder(View row){
            mtitle=(TextView)row.findViewById(R.id.mtitle);
            maddress = (TextView)row.findViewById(R.id.address);
            Icon = (ImageView)row.findViewById(R.id.Micon);
    
        }
    
    //Here populate the row with the data from your database
        void populateFrom(Cursor c, meetingHelper helper){
    
                 mtitle.setText(helper.getMettingTitle(c));
                 maddress.setText(helper.getAddress(c));
    

    This should do it. Just substitute your informations where it should be. This is a tutorial ive put together for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to list several elements that are coming from a database source A
I have a list of 10 data objects that I want to insert/update to
I want to make a drop-down list from scratch. Can anyone please tell me
I want to make a search method from a list of Restaurants. The user
I want to make a long list short by hiding some elements in long
I want to make a query to list cats that took longer than average
I want to make it so the item I have selected in the list
I have input data that consists of a list of subject id's and 2
I have a list of 50 items and I want to extract some other
I have to make own contact list, where i want to put section headers.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.