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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:54:05+00:00 2026-06-01T19:54:05+00:00

I have successfully created a table using SQlite in android. There is a column

  • 0

I have successfully created a table using SQlite in android. There is a column for sex( male/female) in the database. What I would like to do is to is to check the sex type and display a male/female icon depending on the type. I have used setViewBinder() which passes the column index(which column exactly i don’t know ), but I believe we can use this to check the sex column. Is there a better way to do this?

        ListView lv=(ListView)findViewById(R.id.mylist);


         dbh = new DatabaseHelper(this);

           c = dbh.getReadableDatabase().rawQuery("SELECT _id, " + 
                   DatabaseHelper.NAME + 
           ", " + DatabaseHelper.LASTNAME + 
           ", " + DatabaseHelper.ans2 + ", " + DatabaseHelper.SEX + 
           " FROM " +
           DatabaseHelper.TABLE_NAME, null); // initializing 


  String[] dataFrom ={DatabaseHelper.NAME, DatabaseHelper.LASTNAME, DatabaseHelper.ans2, DatabaseHelper.SEX};
  int[] dataTo = {R.id.name, R.id.value1, R.id.value2, R.id.icon};

  SimpleCursorAdapter adapter = new SimpleCursorAdapter(this, 
               R.layout.row, c, dataFrom, dataTo);
  adapter.setViewBinder(new ViewBinder(){


       public boolean setViewValue(View view, Cursor cursor,
               int columnIndex) {
           if (view.getId() == R.id.icon) {
               int sex = cursor.getInt(columnIndex);
               String s = String.valueOf(sex);
               if (s == "male") {
                   ((ImageView) view).setImageResource(R.drawable.male);
               } else if (s == "female"){
                   ((ImageView) view).setImageResource(R.drawable.female);
               }

               return true;    
           } else {
               return false;
           }

       }

   });
lv.setAdapter(adapter);
  • 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-01T19:54:06+00:00Added an answer on June 1, 2026 at 7:54 pm

    The method bindView allows you to set/check your data easily because you receive:

    • you cursor positioned to the actual position
    • the view in which you can place your data
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created an sqlite table using the following statement: CREATE TABLE IF NOT
I have created table using this command successfully create table Person( first_name varchar(25) not
I have a table created with PHP from an Sql Database that successfully displays
i have created table using Sqlite3.and also inserted record in that table.its running successfully.but
I have successfully created a database and performed my first migration using: class CreateUsers
I have created a comment box successfully using PHP with MySQL. The comment table
I have File-Stream enabled database. I have created table with column that has the
I have used zohmg and successfully created mapper, table in HBase and test-imported my
I have a database manager which successfully loads a string from my sqlite database,
I have successfully created an app that reads from a bundled .plist file and

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.