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 8416369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:44:04+00:00 2026-06-10T01:44:04+00:00

I want to populate list view from arraylist returned from ormlite here is code

  • 0

I want to populate list view from arraylist returned from ormlite

here is code where I retrieve data from ormlite

how can i populate listview with all colymns of my table

public class dinnerList extends Activity {
ArrayList<CanteenTagEntry> dinnerlist;
ListView lv;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.listview_item_row);

    Context con = getApplicationContext();
    DatabaseHelper dbHelper = new DatabaseHelper(con);
    ICanteenLogRepository canteenrepo = dbHelper.getCanteenLogRepository();
    try {
        dinnerlist = (ArrayList<CanteenTagEntry>) canteenrepo.Retrieve();
        System.out.print(dinnerlist);
    } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    lv = (ListView) findViewById(R.id.list);
    lv.setAdapter(new CanteenAdapter(this, dinnerlist));

and my adapter class is below

public class CanteenAdapter extends BaseAdapter {
    private Context context;
    private List<CanteenTagEntry> lis;

    public CanteenAdapter(Context c, List<CanteenTagEntry> li) {
        // TODO Auto-generated method stub
        context = c;
        lis = li;
    }

    public int getCount() {
        // TODO Auto-generated method stub
        return lis.size();
    }

    public Object getItem(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public long getItemId(int position) {
        // TODO Auto-generated method stub
        return position;
    }

    public View getView(int position, View convertView, ViewGroup parent) {
        // TODO Auto-generated method stub

        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);

        if (convertView == null) {
            convertView = inflater
                    .inflate(R.layout.listview_item_row, null);
        }

        TextView textview1 = (TextView) convertView
                .findViewById(R.id.Title1);
        TextView textview2 = (TextView) convertView
                .findViewById(R.id.Title2);
        TextView textview3 = (TextView) convertView
                .findViewById(R.id.Title3);
        TextView textview4 = (TextView) convertView
                .findViewById(R.id.Title4);

        return convertView;

    }

}

thanx in advance

  • 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-06-10T01:44:06+00:00Added an answer on June 10, 2026 at 1:44 am

    you have to get those values form the list like this in adapter getView() method

    CanteenTagEntry entry = new CanteenTagEntry();
    entry = lis.get(position);
    

    look at this tutorial Custom adapter for listview it will solve your problem..

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

Sidebar

Related Questions

I want to populate a list from my database. I have the following code:
I have an xml data file and I want to populate a listview in
I'm wondering how I can populate a text box in my view from a
I want to be able to fetch a row from a list view and
In ASP.net MVC: How should/Can I pass Form data (From the View) to the
I want to populate a select list such that it increments for each 5
I am trying to populate a select list with time. I want to create
I have a jquery mobile list. This list is populated with data. I want
I want to populate my database with test data my user and profile models
I have a listview that's populated by rows that get their data from a

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.