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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:31:39+00:00 2026-05-23T16:31:39+00:00

I am trying to separate different columns of data that appear in my listview.

  • 0

I am trying to separate different columns of data that appear in my listview. The code for the adapter is as follows:

public class SQLiteDemo extends ListActivity {

    private SQLiteDatabase database;

    private CursorAdapter dataSource;


    private static final String fields[] = { "firstname", "lastname", "resourceid", BaseColumns._ID };

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
        DatabaseHelper helper = new DatabaseHelper(this);
        database = helper.getWritableDatabase();
        Cursor data = database.query("cards", fields, null, null, null, null,
                null);

        dataSource = new SimpleCursorAdapter(this, R.layout.second, data, fields,
                new int[] { R.id.firstname, R.id.secondname, R.id.name });

        ListView view = getListView();
        view.setHeaderDividersEnabled(true);
        view.addHeaderView(getLayoutInflater().inflate(R.layout.second, null));

        setListAdapter(dataSource);

I defined the listview in my layout file (do I need to do this for the inflater view?)

I have tried adding the dividers as follows….

   <ListView android:id="@android:id/list" 
             android:layout_width="fill_parent"
             android:layout_height="fill_parent" 
             android:visibility="visible"
             android:divider = "@android:color/transparent"
             android:dividerHeight ="10.sp" />

There does not seem to be any difference after adding the divider items; what am I doing wrong?

To be clear, I am a complete android noob, not looking for a complete answer (although they can be useful sometimes) just a nudge in the right direction would be more than enough. Thanks guys!

EDIT WITH R.layout.second

<?xml version="1.0" encoding="utf-8" ?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
                android:layout_height="wrap_content" 
                android:id="@+id/rowLayout" 
                android:orientation="horizontal" 
                android:layout_width="fill_parent">
  <TextView     android:layout_width="wrap_content"
                android:layout_alignParentTop = "true"
                android:layout_alignParentLeft="true" 
                android:layout_height="wrap_content" 
                android:id="@+id/firstname" 
                android:text="FirstName"/> 
  <TextView     android:layout_width="wrap_content" 
                android:layout_toRightOf = "@+id/firstname"
                android:layout_height="wrap_content" 
                android:id="@+id/secondname" 
                android:text="SecondName" 
                />
  <TextView     android:layout_width="wrap_content" 
                android:layout_toRightOf = "@id/secondname" 
                android:layout_height="wrap_content" 
                android:id="@+id/name" 
                android:text="ResourceID" 
                />
   <ListView android:id="@android:id/list" 
             android:layout_width="fill_parent"
             android:layout_height="fill_parent" 
             android:visibility="visible"
             android:dividerHeight ="10.sp" />

  </RelativeLayout>

I have removed the divider transparency now that I know what it does.

  • 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-23T16:31:40+00:00Added an answer on May 23, 2026 at 4:31 pm

    You have a misunderstanding. You are using the same Layout (R.layout.second) for two different things.
    You need one Layout for the whole screen that contains a ListView (i.e. R.layout.second).

    setContentView(R.layout.second)
    

    And then you use an other Layout (i.e. mycell.xml) to define the looks of a sigle row in that ListView.

    new SimpleCursorAdapter(this, R.layout.mycell, data, fields, new int[] { R.id.firstname, R.id.secondname, R.id.name });
    

    The divider is drawn horizontally for each row in your database. You made it invisible.

    If you want to have dividers between firstname,lastname , etc (for each column) you have to edit the Layout you are using for the rows (R.layout.mycell).

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

Sidebar

Related Questions

I am trying to Join 2 separate columns from 2 different sheets to make
I am trying to write separate logs for different packages using log4j. I am
I'm trying to separate the views for the different platforms into different subfolders. I
I'm trying to maintain separate random seeds for different clients (from server app). random_r/srandom_r(linux
In one textview I'm trying to separate text stylings on different words. So far
I am trying to separate my worker code from my GUI code into an
I'm trying to separate a Java Library, that is used by multiple Android services,
I am trying to separate a few things in here. I have a program
I am trying to separate my logic for better readability and re-useability. I am
I'm trying to basically trying to separate a specific amount of text from the

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.