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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:15:27+00:00 2026-06-13T16:15:27+00:00

i doing the application which can display all the data in listView . But

  • 0

i doing the application which can display all the data in listView . But when i compile my app, nothing display in listView . No any errors in program , i really no sure which part is wrong .

Anyone know what the problem or something wrong in my program?

main.java

package com.example.shoppingassistantnew;

import java.util.ArrayList;



import greendroid.app.GDActivity;
import greendroid.app.GDListActivity;
import greendroid.widget.ActionBar;
import greendroid.widget.ActionBarItem;
import greendroid.widget.ActionBarItem.Type;
import greendroid.widget.QuickAction;
import greendroid.widget.QuickActionBar;
import greendroid.widget.QuickActionGrid;
import greendroid.widget.QuickActionWidget;
import greendroid.widget.QuickActionWidget.OnQuickActionClickListener;

import android.os.Bundle;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.LightingColorFilter;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.CursorAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.support.v4.app.NavUtils;

public class main extends GDActivity{

    private static final int HOME = 2;

    private static final int ADD = 1;

    private static final int EXPAND = 3;



    Cursor model = null;
    ProductDatabaseHelper helper = null;
    ShoppingListAdapter adapter=null;


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setActionBarContentView(R.layout.shoppinglist);


        initActionBar();

        helper = new ProductDatabaseHelper(this);
        ListView listView = (ListView) findViewById(R.id.shoppingList);

        model = helper.getAll();
        startManagingCursor(model);
        adapter = new ShoppingListAdapter(model);
        listView.setAdapter(adapter);


    }
    public void onDestroy(){
        super.onDestroy();
        helper.close();
    }





    private OnQuickActionClickListener mActionListener = new OnQuickActionClickListener() {
        public void onQuickActionClicked(QuickActionWidget widget, int position) {
            if (position == 0) {
                Intent intent2 = new Intent(main.this, AddShoppingList.class);
                startActivity(intent2);
            }
        }
    };



    private void initActionBar() {
        // TODO Auto-generated method stub
        // this.getActionBar().setType(ActionBar.Type.Empty);
        addActionBarItem(Type.Add, ADD);
        addActionBarItem(Type.Edit, EXPAND);
    }

    @Override
    public boolean onHandleActionBarItemClick(ActionBarItem item, int position) {
        // TODO Auto-generated method stub
        switch (item.getItemId()) {
        case ADD:
            Intent intent = new Intent(main.this, AddShoppingList.class);
            startActivity(intent);
            break;
        case HOME:
            Intent intent1 = new Intent(main.this, main.class);
            startActivity(intent1);
            break;
        case EXPAND:
            onShowGrid(item.getItemView());
            break;

        }
        return super.onHandleActionBarItemClick(item, position);
    }

    class ShoppingListAdapter extends CursorAdapter{

        public ShoppingListAdapter(Cursor c) {
            super(main.this, c);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void bindView(View row, Context ctxt, Cursor c) {
            // TODO Auto-generated method stub
            ShoppingListHolder holder=(ShoppingListHolder)row.getTag();
        }


        @Override
        public View newView(Context ctxt, Cursor cursor, ViewGroup parent) {
            // TODO Auto-generated method stub
            LayoutInflater inflater=getLayoutInflater();
            View row=inflater.inflate(R.layout.row,parent,false);
            ShoppingListHolder holder=new ShoppingListHolder(row);
            row.setTag(holder);
            return(row);

        }
    }
        static class ShoppingListHolder{
            private TextView barcode=null;
            private TextView format=null;

            ShoppingListHolder(View row){
                barcode=(TextView)row.findViewById(R.id.barcode);
                format=(TextView)row.findViewById(R.id.format);

            }
            void populateFrom(Cursor c,ProductDatabaseHelper helper){
                barcode.setText(helper.getBarcode(c));
                format.setText(helper.getFormat(c));


            }

        }




    }

addShoppingList.java

package com.example.shoppingassistantnew;

import com.cyrilmottier.android.greendroid.R;

//import com.example.shoppingassistantnew.main.ProductData;


import android.app.ActionBar.LayoutParams;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.database.Cursor;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.ListView;
import greendroid.app.GDActivity;

public class AddShoppingList extends Activity implements OnClickListener{
    //private static final ProductData mProductData = new ProductData();
    ProductData mProductData=new ProductData();
    Button mSaveBttn;
    EditText mBarcodeEdit;
    EditText mFormatEdit;
     ProductDatabaseHelper helper=null;

    //Cursor model=null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
        setContentView(R.layout.addshoppinglist);

        mSaveBttn = (Button) findViewById(R.id.saveBttn);
        mSaveBttn.setOnClickListener(this);
         dt=(DatePicker)findViewById(R.id.datePicker1);
        helper=new ProductDatabaseHelper(this);

    }


    public void onClick(View v) {
        // TODO Auto-generated method stub
        switch(v.getId()){
        case R.id.saveBttn:

            mBarcodeEdit = (EditText) findViewById(R.id.shoppingListNameEdit);
            mFormatEdit = (EditText) findViewById(R.id.shoppingDateEdit);
           mProductData.setBarcode(mBarcodeEdit.getText().toString());
           mProductData.setFormat(mFormatEdit.getText().toString());
           helper.insert(mBarcodeEdit.getText().toString(),mFormatEdit.getText().toString());
           showInfoDialog(this, "Success", "Product saved successfully");
           //model.requery();
        break;
        }
    }
       private void showInfoDialog(Context context, String title, String information) {
            new AlertDialog.Builder (context)
            .setMessage(information)
            .setTitle(title)
            .setPositiveButton("OK", new DialogInterface.OnClickListener() {


                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                }
            }).show();  
        }

}

ProductDatabase.java



  package com.example.shoppingassistantnew;

    import android.content.ContentValues;
    import android.content.Context;
    import android.database.Cursor;
    import android.database.sqlite.SQLiteDatabase;
    import android.database.sqlite.SQLiteDatabase.CursorFactory;
    import android.database.sqlite.SQLiteOpenHelper;
    import android.util.Log;

     class ProductDatabaseHelper extends SQLiteOpenHelper {
        private static final String PRODUCT_TABLE = "products";
        private static final String DATABASE_NAME = "spot_pay.db";
        private static final int SCHEMA_VERSION = 1;
        private SQLiteDatabase db;

        private static final String TAG = null;

        public ProductDatabaseHelper(Context context) {
            super(context, DATABASE_NAME, null,SCHEMA_VERSION);
            // TODO Auto-generated constructor stub
        }

        @Override
        public void onCreate(SQLiteDatabase db) {
            // TODO Auto-generated method stub
            db.execSQL("CREATE TABLE products (_id INTEGER PRIMARY KEY AUTOINCREMENT,barcode TEXT ,format TEXT);");
        }

        @Override
        public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
            // TODO Auto-generated method stub
            db.execSQL("drop table if exists " + PRODUCT_TABLE);
            onCreate(db);
        }

        /*
         * public ProductDatabase(Context context) { ProductDatabaseHelper helper =
         * new ProductDatabaseHelper(context); db = helper.getWritableDatabase();
         * 
         * }
         */
        public Cursor getAll() {
            // TODO Auto-generated method stub
            return (getReadableDatabase()
                    .rawQuery("SELECT _id, barcode, format FROM products ORDER BY barcode",
                    null));
        }

        public void insert(String barcode, String format) {
            ContentValues vals = new ContentValues();
            vals.put("barcode", barcode);
            vals.put("format", format);
        getWritableDatabase().insert("products", null, vals);


        }





        public String getBarcode(Cursor c) {
            // TODO Auto-generated method stub
            return(c.getString(1));
        }

        public String getFormat(Cursor c) {
            // TODO Auto-generated method stub
            return(c.getString(2));
            }
        }

     row.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:orientation="horizontal" 
    android:padding="4dip">
     <LinearLayout
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         android:orientation="vertical" >
         <TextView 
             android:id="@+id/barcode"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
             android:gravity="center_vertical"
             android:textStyle="bold"
             android:singleLine="true"
             android:ellipsize="end"

             />
         <TextView
             android:id="@+id/format"
             android:layout_width="fill_parent"
             android:layout_height="wrap_content"
             android:layout_weight="1"
               android:gravity="center_vertical"
             android:textStyle="bold"
             android:singleLine="true"
             android:ellipsize="end"/>
         </LinearLayout>

</LinearLayout>

ShoppingList.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical" >

<ListView
    android:id="@+id/shoppingList"

    android:layout_width="fill_parent"
    android:layout_height="wrap_content"

   />




</LinearLayout>

output screenshot

  • 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-13T16:15:28+00:00Added an answer on June 13, 2026 at 4:15 pm

    You are not doing anything in your CursorAdapter’s bindView(), so you will never see any data in your rows. You need to do something like this:

    @Override
    public void bindView(View row, Context ctxt, Cursor c) {
        ShoppingListHolder holder=(ShoppingListHolder)row.getTag();
        holder.barcode.setText(c.getString(c.getColumnIndex("barcode"))); 
        holder.format.setText(c.getString(c.getColumnIndex("format")));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im doing an application in which im transfering file through FTP.i succesfully done all
My application contains a line graph which can display 20 or more datasets at
I am doing an application in which I want to get the screen shots
I am doing mail parsing application which required to convert the HTML file to
I have a Silverlight application in which I am doing the following thing to
I am doing an application where I want to grab the content of div,which
Main thread of application is doing some work. There also exists a timer, which
I am doing a project in which i am designing a Text Editor application
I'm writing an application which will display the current image seen by a camera
I am currently developing an application in which I want to display a UserControl

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.