1

Android アプリケーションをプログラミングしており、ユーザーを他の画面に移動するホーム画面のボタンを使用しています。現在、私のボタンはすべて機能しますが、1つだけです。私のホームスクリーンでは、DBUse クラスであるビジネス画面にユーザーを連れて行こうとしています。このボタンをクリックするとエラーが表示され、Android を初めて使用するため、エラーを修正する方法がわかりません。どんな助けでも大歓迎です。

すべてが作成される MainActivity:

package com.think_bloomington;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.database.SQLException;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends Activity {
    private SQLiteDatabase mDB;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    /** Called when the user clicks the Map button */
    public void viewMap(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, MapActivity.class);
        startActivity(intent);
    }

    /** Called when the user clicks the Business button */
    public void viewBusiness(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, DBUse.class);
        startActivity(intent);

    }

    /** Called when the user clicks the Events button */
    public void viewEvents(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, EventActivity.class);
        startActivity(intent);
    }

    /** Called when the user clicks the Facebook button */
    public void viewFacebook(View view) {
        // Do something in response to button
        Intent intent = new Intent(this, FacebookActivity.class);
        startActivity(intent);
    }

    public Cursor getBusinessInfo(String business) throws SQLException {
        // TODO Auto-generated method stub
          return mDB.rawQuery("SELECT business,address,phone,hours,website,type FROM Business  where business like ? Limit 5", new String[]{"%"+business+"%"}); 
    }

    public Cursor getBusinessType(String type)throws SQLException {
        // TODO Auto-generated method stub
        return mDB.rawQuery("SELECT business,address,phone,hours,website,type FROM Business  where type like ? Limit 5", new String[]{"%"+type+"%"}); 
    }
}

ボタンがユーザーを取得しようとしている DBUse クラス:

package com.think_bloomington;

import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;



public class DBUse extends Activity  {
    EditText dEdit;
    DBAdapter data;
    long id;
    public static final String KEY_ROWID = "_id";
    public static final String KEY_BUSINESS = "business";
    public static final String KEY_ADDRESS = "address";
    public static final String KEY_PHONE = "phone";
    public static final String KEY_HOURS = "hours";
    public static final String KEY_WEB = "website";
    public static final String KEY_TYPE = "type";




    @Override
    public void onCreate(Bundle savedInstanceState) {

        // TODO Auto-generated method stub


        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        data = new DBAdapter(this);


        Button buttonName =(Button)findViewById(R.id.buttonName);
        buttonName.setOnClickListener(startName);



        Button buttonType =(Button)findViewById(R.id.buttonType);
        buttonType.setOnClickListener(startType);

        dEdit =(EditText)findViewById(R.id.textView1);

        data.open();

        id =data.insertTitle("BloomingFoods","419 E. Kirkwood Ave. Bloomington, IN", "812-336-5300", "M-Sat:8AM-9PM Sun:9AM-8PM","http://www.bloomingfoods.coop","Grocery");


        id=data.insertTitle("BloomingFoods","316 W. 6th Street Bloomington, IN", "812-333-5300", "M-Sat:7AM-10PM Sun:9AM-9PM","http://www.bloomingfoods.coop","Grocery");

        id=data.insertTitle("BloomingFoods","3220 E. 3rd Street Bloomington, IN", "812-336-5300", "M-Sun:8AM-10PM","http://www.bloomingfoods.coop","Grocery");
        id=data.insertTitle("The Uptown Cafe","102 E. Kirkwood Ave. Bloomington, IN", "812-339-0900", "M-Sat:8AM-9PM Sun:9AM-8PM", "http://www.the-uptown.com/","Cajun-Creole");
        id=data.insertTitle("Crazy Horse","214 W. Kirkwood Ave. Bloomington, IN", "812-336-8877", "M-Sat:11AM-2AM Sun:Noon-Midnight", "http://www.crazyhorseindiana.com/","Restaurant & Live Music");
        id=data.insertTitle("FARMbloomington","108 E. Kirkwood Ave. Bloomington, IN", "812-323-0002", "Tue.-Thurs.:8AM-10PM F:8AM-1AM Sat: 10AM-3AM Sun: 10AM-10PM","http://www.farm-bloomington.com","Grocery");
        id=data.insertTitle("Laughing Planet","322 E. Kirkwood Ave. Bloomington, IN", "812-323-2233", "M-Sun:11AM-9PM","http://www.facebook.com/laughingplanetbtown","Burritos & Salads");
        id=data.insertTitle("Soma Coffeehouse","322 E. Kirkwood Bloomington, IN", "812-331-2770", "M-Sat:7AM-11PM Sun:8AM-11PM","http://www.iheartsoma.com","Coffee House");
        id=data.insertTitle("Upland Brewing Company","350 W. 11th St. Bloomington, IN", "812-336-2337", "M-Thurs:11AM-Midnight F-Sat:11AM-1AM Sun: Noon-Midnight","http://www.uplandataeer.com","Brewery & Restaraunt");
        id=data.insertTitle("Nick's English Hut","423 E. Kirkwood Bloomington, IN", "812-332-4040", "M-Sat:11AM-2AM Sun: Noon-Midnight","http://www.nicksenglishhut.com","Bar & Restaraunt");
        id=data.insertTitle("The Village Deli","409 E. Kirkwood Ave. Bloomington, IN", "812-336-2303", "M-F:7AM-8PM Sat-Sun 8AM-8PM","http://www.villagedeli.biz","Breakfast,Lunch,Dinner");
        id=data.insertTitle("Rachael's Cafe","300 E. 3rd St. Bloomington, IN", "812-330-1882", "M-F:8AM-9PM Sat-Sun 9AM-9PM","http://www.rachaelscafe.com","Coffee House & Live Music");
        id=data.insertTitle("Happy Pig","1604 W. 7th St. Bloomington, IN", "None", "W:Sample Gates Noon-3PM Thurs:Sample Gates Noon-3PM F:Atlas Bar 11:30PM-3:30AM Sat:Courthouse Square 11:30PM-3:30AM","http://www.happypigbloomington.com","BBQ Streetfood");
        id=data.insertTitle("Lennie's Restaurant and Brewpub","1795 E. 10th St. Bloomington, IN", "812-323-2112", "Sun-Th:11AM-11PM F-Sat 11AM-Midnight","http://www.lenniesgourmetpizza.com","Bar & Restaurant");
        id=data.insertTitle("Pizza X","1791 E. 10th St. Bloomington, IN", "812-339-7737", "Sun-Tues:11AM-2AM Wed-Thur: 11AM-3AM F-Sat:11AM-4AM","http://www.pizzaxbloomington.com","Pizza");
        id=data.insertTitle("Pizza X","1610 W. 3rd St. Bloomington, IN", "812-332-2522", "Sun-Wed:4PM-Midnight Thur: 4PM-3AM F-Sat:4PM-4AM","http://www.pizzaxbloomington.com","Pizza");
        id=data.insertTitle("Pizza X","877 S. College Mall Rd. Bloomington, IN", "812-355-5000", "Sun-Wed:4PM-Midnight Thur: 4PM-3AM F-Sat:4PM-4AM","http://www.pizzaxbloomington.com","Pizza");
        id=data.insertTitle("Pizza X","2443 S. Walnut St. Pk. Bloomington, IN", "812-332-8500", "Sun-Wed:4PM-Midnight Thur: 4PM-3AM F-Sat:4PM-4AM","http://www.pizzaxbloomington.com","Pizza");
        id=data.insertTitle("The Atlas Bar","209 S. College Ave.  Bloomington, IN", "812-334-4435", "M-F:5PM-3AM Sat-Sun:7PM-3AM","http://www.atlasballroom.com","Bar");
        id=data.insertTitle("The Bishop","123 S. Walnut St.  Bloomington, IN", "812-333-4700", "Mon-Sat:7PM-3AM","http://www.thebishopbar.com","Bar & Live Music");
        id=data.insertTitle("Oliver Winery","8024 N. State Road 37 Bloomington, IN", "812-876-5800", "Mon-Sat:10AM-6PM Sun: 12PM-6PM Tours:F-Sat Noon-4:30PM Sun:1PM-4:30PM","http://www.oliverwinery.com","Winery");
        id=data.insertTitle("Revolution Bike and Bean","401 E. 10th St. Bloomington, IN", "812-336-0241", "Mon-Fri:10AM-6PM Sat: 10AM-5PM","http://www.revolutionbikeandataean.com","Coffee House & Bike Repair Shop");
        id=data.insertTitle("Mother Hubbard's Cupboard","1010 S. Walnut Bloomington, IN", "812-355-6843", "Mon-Fri:4PM-6PM","http://www.mhcfoodpantry.org","Food Pantry Service & Non-Profit");
        id=data.insertTitle("Patricia's Wellness Arts Cafe and Quilter's Comfort Teas","725 W. Kirkwood Ave. Bloomington, IN", "812-331-0886", "Mon-Sat:11AM-5PM First Friday: 11AM-8PM","http://www.hartrock.net/cafe.htm","Tea House & Holistic and Naturopathic & Reiki & Counseling");
        id=data.insertTitle("One World Catering and Events","2234 W. Industrial Pk. Dr. Bloomington, IN", "812-334-3663", "","http://www.oneworldcateringandevents.com","Catering");
        id=data.insertTitle("Nelson's Furniture Restoration","6573 S. Old State Road 37 Bloomington, IN", "812-824-7769", "M-F:10AM-6PM","http://www.nelsonrestoration.com","Furniture Restoration");
        id=data.insertTitle("NR Hiller Design, Inc","3450 S. Garrison Chapel. Rd. Bloomington, IN", "812-825-5872", "Hours By Appointment","http://www.nrhillerdesign.com","Furniture Design & Furniture Building & Cabinet-Making & Furniture");
        id=data.insertTitle("Showers Inn Bed and Breakfast","430 N. Washington St. Bloomington, IN", "812-334-9000", "Hours By Appointment","http://www.showersinn.com","Bed and Breakfast");
        id=data.insertTitle("Monroe County History Center","202 E. 6th St.  Bloomington, IN", "812-332-2517", "Tues-Sat:10AM-4PM","http://www.monroehistory.org","Museum");
        id=data.insertTitle("WFHB","108 W. 4th St. Bloomington, IN", "812-323-0320", "Hours By Appointment","http://www.wfhb.org","Radio Station & Non-Profit");
        id=data.insertTitle("Brinegar Eye Care","4001 E. 3rd St. Suite 8 Bloomington, IN", "812-339-7995", "Mon-F:9AM-5PM","http://www.brinegareyecare.com","Optometrist");
        id=data.insertTitle("Sole Sensations","414 S. College Ave. Bloomington, IN", "812-331-1962", "Mon:10AM-6PM Tues:10AM-8PM Wed:10AM-6PM Thurs:10AM-8PM Sat:10AM-5PM","http://www.solesensations.com/Soul-Inspirations.html","Orthotics & Shoes");
        id=data.insertTitle("Bloomignton Area Birth Services (BABS)","2458 S. Walnut St. Bloomington, IN", "812-337-8121", "Mon-Fri:10AM-5PM Sat:10AM-2PM" ,"http://www.bloomingtonbirth.org","Holistic and Naturopathic & Non-Profit & Gifts & Toys & Books & Maternity/Nursing Wear & Prenatal and Postnatal Yoga & Childatairth Classes & Breastfeeding Classes and Consultation");
        id=data.insertTitle("Karen Knight, LMHC Counseling Services","115 N. College Ave Suite 214 Bloomington, IN", "812-361-3601", "Mon-Fri:9AM-8PM By Appointment" ,"http://www.karenknight.net","Mental Health & Counseling");
        id=data.insertTitle("Mister Buck's Genuinely Good Pet Food Compnay","319 S. Mitchell Bloomington, IN", "812-384-3853", "24hr Internet Access" ,"http://www.mrbuckspetfood.com","Pet Care");
        id=data.insertTitle("Center for Sustainable Living","323 S. Walnut St. Bloomington, IN", "812-332-8796", "24hr Internet Access" ,"http://www.simplycsl.org","Non-Profit");
        id=data.insertTitle("Friends of Art Bookshop","1201 E. 7th St. (Fine Arts Building, Indiana University) Bloomington, IN", "812-855-7498","M-Thurs:9AM-6PM Sat-Sun:1PM-5PM" ,"http://www.fa.indiana.edu/foart/","Non-Profit & Books & Art Books & Textbooks");
        id=data.insertTitle("Cardinal Stage Company","900 S. Walnut St. Bloomington, IN", "812-323-3020", "24hr Internet Access" ,"http://www.cardinalstage.org","Non-Profit & Theater");
        id=data.insertTitle("Bloomington Playwrights Project","107 W. 9th St. Bloomington, IN", "812-334-1188", "Mon-Fri:9AM-5PM" ,"http://www.newplays.org","Non-Profit");
        id=data.insertTitle("Boxcar Books","408 E. 6th St. Bloomington, IN", "812-339-8710", "Mon-Fri: 11AM-9PM Sat:10AM-9PM Sun:10AM-5PM" ,"http://www.boxcarbooks.org","Non-Profit & Books & Textbooks");
        id=data.insertTitle("Community Foundation of Bloomington and Monroe County,Inc.","101 W. Kirkwood Ave. Suite 321 Bloomington, IN", "812-333-9016", "Mon-Fri:8:30AM-5PM" ,"http://www.cfbmc.org","Non-Profit");
        id=data.insertTitle("Windfall Dancers","1101 N. Dunn St. Bloomington, IN", "812-334-0506", "24hr Internet Access" ,"http://www.windfalldancers.org","Non-Profit & Modern Dance & Dance");
        id=data.insertTitle("The Updraft Supplementary Scholarship Project, Inc. (USSP)","403 E. 6th St. Bloomington, IN", "812-961-3553 Toll Free:877-451-8535", "Mon-Fri:9AM-5PM" ,"http://www.usspkids.org","Non-Profit");
        id=data.insertTitle("Story Insights","P.O. Box 2264. Bloomington, IN 47402", "812-340-0479", "24hrs" ,"http://storyinsights.com","Non-Profit & Story Development & Project Management & Web Design");
        id=data.insertTitle("Middle Way House","P.O. Box 95 Bloomington, IN 47402", "Administration:812-333-7404 Crisis Line:812-336-9063", "24hr Internet Access" ,"http://www.middlewayhouse.org","Non-Profit");
        id=data.insertTitle("Baugh Enterprises, Inc","1611 S Rogers St. Bloomington, IN", "812-334-8189", "Mon-Fri:8:30AM-5PM" ,"http://www.baughenterprises.com","Printing Service & Printwork Design");
        id=data.insertTitle("White Rabbit","118 W. 6th St. Bloomington, IN", "812-339-5020 Fax:812-339-7847", "Mon-Fri:8:30AM-5PM" ,"http://www.whiterabbitcopyservice.com","Printing Service");
        id=data.insertTitle("Mr. Copy","501 E. 10th St. Bloomington, IN", "812-334-2679", "Mon-Fri:9AM-6PM Sat: Noon-5PM" ,"http://www.copysales.com","Printing Service & Graphic Design");
        id=data.insertTitle("Rosenplot Design","P.O Box 1083 Bloomington, IN 47402", "812-822-2077 Fax:812-822-2077", "Mon-Fri:8:30AM-5PM" ,"http://www.rosenplotdesign.com","Graphic Design");
        id=data.insertTitle("Patrick Siney Art Direction and Design","1303 S. Stull Ave. Bloomington, IN", "812-334-0019", "Mon-Fri:8:30AM-5PM" ,"http://www.patricksiney.com","Graphic Design & Web Design");
        id=data.insertTitle("Bloomington Cooking School","115 N. College Ave. Suite 014 Bloomington, IN ", "812-333-7100", "Mon-Fri:8:30AM-5PM" ,"http://www.bloomingtoncookingschool.com","Cooking Class");
        id=data.insertTitle("Bloomington Pedal Power","", "812-325-2777", "Mon-Wed:8AM-5PM Thurs-Sat:8AM-2AM" ,"http://www.bloomingtonpedalpower.com","Delivery Service");
        id=data.insertTitle("Backyard Classrooms LLC","Elletsville,IN", "812-844-5826", "Mon-Sun:8AM-8PM" ,"http://www.backyardclassroms.com","Education & Group Events & Agritourism");
        id=data.insertTitle("Kemp & Associates","403 E. 6th St. Bloomington,IN", "812-961-3533 Fax:812-961-2072 Toll Free:877-451-8535", "By Appointment Mon-Fri:9AM-5PM" ,"http://www.kempandassociates.com","Financial Retirement Planning & Estate Planning & Life and Health Insurance Planning & Family Office Services");
        id=data.insertTitle("ISU The May Agency","1327 N. Walnut St. Bloomington, IN", "812-334-2400", "Mon-Fri:9AM-5PM" ,"http://www.MayAgency.com","Life and Health Insurance Planning");
        id=data.insertTitle("LNoggleDesigns","", "812-320-5865", "Flexible" ,"http://www.lnoggledesigns.com","Illustration & Architectural Design & Creative Consultation & Architecture");
        id=data.insertTitle("Sustainability Dashboard Tools LLC","300 W. Hillside Dr. Bloomington, IN", "812-269-2805", "Mon-Fri:9AM-5PM" ,"http://www.green2sustainable.com","Sustainability Services");
        id=data.insertTitle("PrimeSource Office Products, Inc","5015 N. Capitol Ave. Bloomington, IN", "812-876-1143", "Mon-Fri:8AM-5PM" ,"http://www.primesourceop.com","Office Supply");
        id=data.insertTitle("The Dog Knows Detection","P.O. Box 3122 Bloomington, IN 47401", "812-334-7959", "By Appointment" ,"http://www.thedogknowsdetection.com","Pest Control");
        id=data.insertTitle("Easy Go Lawn Care","5929 W. Koontz Rd. Bloomington, IN", "812-320-2844", "By Appointment" ,"http://locallawncareservice.com","Lawn Care & Gutter Cleaning & Snow Removal");
        id=data.insertTitle("Clutter Wrangler","", "812-334-2400", "By Appointment" ,"http://www.clutterwrangler.com","Professional Organizer");
        id=data.insertTitle("Ann Schertz Photography","P.O. Box 1403 Bloomington, IN 47402", "812-327-3402", "By Appointment" ,"http://www.annschertz.com","Photography");
        id=data.insertTitle("The Ryder Magazine and Film Series","Bloomington, IN", "812-339-2002", "" ,"http://www.theryder.com","Magazine & Film Showings");
        id=data.insertTitle("Bloom Magazine","P.O. Box 1204 Bloomington, IN 47402", "812-323-8959", "" ,"http://www.magbloom.com","Magazine");
        id=data.insertTitle("Gallagher Properties","107 N. College Ave. Bloomington, IN", "812-333-5252", "By Appointment" ,"http://www.homefinder.org/findrealtor/findRealtor-AgentSearch.asp?mode=Office_Clicked&BrokerID=175","Housing & Property Management & Commercial Real Estate");
        id=data.insertTitle("Jeanne Walters Real Estate","107 E. 6th St. Bloomington, IN", "866-877-6677", "By Appointment" ,"http://www.jeannewalters.com","Housing");
        id=data.insertTitle("Olympus Properties","2620 N. Walnut St. Bloomington, IN", "812-334-8200", "Mon-Fri:8:30AM-4:30PM" ,"http://www.olympusproperties.com","Housing & Property Management");
        id=data.insertTitle("Blue Studio Gallery","116.5 S. College Ave. Upstairs#10 Bloomington, IN", "812-361-7504", "Mon/Wed/Thurs:Noon-6PM F-Sat:3PM-6PM By Appointment" ,"http://www.bluestudiogallery.com","Art & Gallery");
        id=data.insertTitle("A.Z. Vintage","236 N. Morton St. Bloomington, IN", "812-333-1960", "Mon:By Appointment Tues-Sat:10AM-7PM Sun:Noon-5PM" ,"http://www.azvintagebloomington.com","Art & Gifts & Shoes & Furniture & Handmade Art & Jewelry & Clothing & Vintage");
        id=data.insertTitle("Sweany Artworks-Wandering Turtle On-Line","P.O. Box 1476 Bloomington, IN 47402", "812-219-2992", "By Appointment" ,"http://www.wanderingturtle.com","Art & Gifts & Online Art Gallery");
        id=data.insertTitle("Paper Crane Gallery and Studio","116 S. Grant St. Bloomington, IN", "", "Wed-Fri:2PM-8PM Sat:10AM-4PM Sun:Noon-5PM" ,"http://www.papercranegallery.org","Art & Gifts & Illustration");
        id=data.insertTitle("Conduit Press","Online Store", "", "24hr Web" ,"http://conduit-press.com","Art & Gifts & Books & Art Books");
        id=data.insertTitle("Sadly Harmless","Online Store", "", "24hr Web" ,"http://www.sadlyharmless.com","Art & Illustration");
        id=data.insertTitle("Opportunity House", "907 W. 11th St. Bloomington,IN","812-336-2443","Donate:8:30AM-3PM Shop:9AM-2PM", "http://www.mcum.org/opportunity_house.html", "Gifts & Toys & Books & Shoes & Window Treatment & Furniture & Jewelry & Clothing & Vintage & Reasle");
        id=data.insertTitle("Moda Industria", "2120 W. Industrial Park Dr. Bloomington,IN","812-606-7185","24hr Web Studio by appointment", "http://www.modaindustry.com", "Gifts & Furniture & Handmade Art & Jewelry & Art");
        id=data.insertTitle("Athena", "116 N. Walnut Ave. Bloomington,IN","812-339-0734","Mon-Thur:10:30AM-7PM Fri-Sat:10:30AM-8:30PM Sun:Noon-5:00PM", "http://www.btownboutiques.com/accessories/athena.com", "Gifts");
        id=data.insertTitle("Green Nursery", "509 E. Hillside Dr. Suite B104 Bloomington,IN","812-339-5090","Mon-Fri:10AM-5:30PM Sat:10AM-5PM", "http://www.thegreennursery.com", "Gifts & Toys & Online Option & Cloth Diapers & Baby Carriers& Baby Items");
        id=data.insertTitle("Melody Music Shop LLC", "402 W. 6th St. Bloomington,IN","812-336-6319","Mon-Thurs:11:30AM-7:30PM Fri-Sat:11:30AM-5PM", "http://www.melodymusicshop.com", "Music & Musical Instruments");
        id=data.insertTitle("Landlocked", "202 N. Walnut St. Bloomington,IN","812-339-2574","Mon-Sat:11:30AM-7:30PM Sun:Noon-5PM", "http://www.landlockedmusic.com", "Music");
        id=data.insertTitle("Nature's Crossroads Seed Company", "230 W. Church Lane Bloomington,IN","Customer Service:812-327-9612 Office&Fax:812-824-3727","By Appointment", "http://www.naturescrossroads.com", "Seeds & Gardening Supplies & Certified Organic Farm");
        id=data.insertTitle("Discount Blinds & Verticals Inc.", "3910 S. Walnut St. Bloomington,IN","812-333-8412","By Appointment", "http://www.blindsandverticals.com", "Window Treatment");
        id=data.insertTitle("American Futons", "105 S. Walnut St. Bloomington,IN","812-333-1305","Wed-Fri:Noon-6PM Sat-Sun Noon-4PM", "http://www.bloomington.in.us/~futons/futons.html", "Furniture & Futons");
        id=data.insertTitle("Creating Harmony LLC", "Online Store","888-325-1963","24hr Web Service", "http://www.CreatingHarmonyLLC.com", "Baby Items & Bath and Body & Skincare & Spiritual Development & Meditation");
        id=data.insertTitle("Soapy Soap Company", "2786 E. Bressingham Way Bloomington,IN","812-269-8812","By Appointment", "http://www.soapysoapcompany.com", "Bath and Body & Personal Care Products");
        id=data.insertTitle("Full Moon Milk Soaps", "Online Store","","24hr Web Service", "http://www.fullmoonmilksoaps.com", "Bath and Body");
        id=data.insertTitle("Know Yoga Know Peace", "234 N. Morton Street Bloomington, IN","812-822-1101","View Website for Hours", "http://www.knowyogakowpeace.org", "Hatha Yoga & Hot Yoga");
        id=data.insertTitle("La Rua Enamels", "Bloomington, IN","Online Store","View Website for Hours", "http://www.laruaenamels.net", "Functional Art & Art");
        id=data.insertTitle("By Hand Gallery", "101 W. Kirkwood Suite 109 Bloomington, IN","812-334-3255","Mon-Sat: 10AM-5:30PM First Friday & December:10AM-7:30PM", "http://www.bloomington.in.us/~byhand/", "Gallery");
        id=data.insertTitle("Panache School of Ballroom and Social Dance", "325 E. Winslow Rd. Bloomington, IN","812-822-0050","Mon-Fri: 3PM-10PM Sat:10AM-2PM", "http://www.panachedance.com", "Ballroom and Social Dance Lessons & Dance");
        id=data.insertTitle("Studio Cypher", "115 N. College Ave. Bloomington, IN","812-392-4263","Mon-Fri: 8Am-5PM", "http://www.studiocypher.com", "Game Design & Web Design");
        id=data.insertTitle("David Martin Design", "2112 S. Susie St. Bloomington, IN","812-650-4405","By Appointment", "http://www.davidmartindesign.com", "Web Design");
        id=data.insertTitle("My Edible Eden LLC", "P.O. Box 613 Bloomington, IN 47402","812-202-6830","By Appointment", "http://www.myedibleeden.com", "Certified Permaculture Designer & Urban Farm Consultant");
        id=data.insertTitle("T.A. Fuller Homes Inc", "Bloomington,IN","812-824-3300","By Appointment", "http://www.tafullerhomes.com/index.html", "Architecture & Home Building");
        id=data.insertTitle("Amity Montessori School LLC", "401 E. Allen St. Bloomington, IN","Contact Via Website","By Appointment: 8:30AM-4:30PM", "http://www.amitymontessorischool.com", "Montessori & Preschool-Kindergarten");
        id=data.insertTitle("Free University of Monroe County", "P.O. Box 5152 Bloomington, IN 47407","freeumc@gmail.com","By Appointment", "http://www.facebook.com/freeumc", "Adult Personal Enrichment");
        id=data.insertTitle("BCT Box Office", "114 E. Kirkwood Ave. Bloomington, IN ","812-333-3020","Available By Website", "http://www.buskirkchumley.org", "Live Music & Theater & Tickets");
        id=data.insertTitle("The Comedy Attic", "123 S. Walnut St. Bloomington, IN ","812-336-5233","Wed-Sat 8PM-Close Fri/Sat 8PM-Close", "http://www.comedyattic.com", "Comedy");


    }



//displays the data

    public void DisplayTitle(Cursor c)  {
        Toast.makeText(this,
        "Name: " + c.getString(1)+"\n"+
        "Address:" + c.getString(2)+"\n"+
        "Phone:" + c.getString(3)+"\n"+
        "Hours:" + c.getString(4)+"\n"+
        "Website"+ c.getShort(5)+
        "Type" + c.getShort(6),
        Toast.LENGTH_LONG).show();


    }

    //Informs the user what is being searched
    private OnClickListener startName=new OnClickListener(){

        public void onClick (View v) {

                Cursor cur=data.getBusinessInfo(dEdit.getText().toString());
                String result="";

                int iName=cur.getColumnIndex(KEY_BUSINESS);
                int iAddress=cur.getColumnIndex(KEY_ADDRESS);
                int iPhone=cur.getColumnIndex(KEY_PHONE);
                int iHours=cur.getColumnIndex(KEY_HOURS);
                int iWebsite=cur.getColumnIndex(KEY_WEB);
                int iType=cur.getColumnIndex(KEY_TYPE);
                Toast.makeText(DBUse.this, "Searching by Name", Toast.LENGTH_LONG).show();
            //  log.d("result",DBUse.getString(0));
                for(cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()){
                    result=result
                            +cur.getString(iName) + " "
                            +cur.getString(iAddress) + " "
                            +cur.getString(iPhone) + " "
                            +cur.getString(iHours) + " "
                            +cur.getString(iWebsite) + " "
                            +cur.getString(iType) + " " + " ";
                    Toast.makeText(DBUse.this, result, Toast.LENGTH_LONG).show();
            };

                return;
            }

        };


//Informs the user what is being searched
    private OnClickListener startType=new OnClickListener(){

            public void onClick (View v){

                    // TODO Auto-generated method stub
                    Cursor cur=data.getBusinessType(dEdit.getText().toString());
                    String result="";

                    int iName=cur.getColumnIndex(KEY_BUSINESS);
                    int iAddress=cur.getColumnIndex(KEY_ADDRESS);
                    int iPhone=cur.getColumnIndex(KEY_PHONE);
                    int iHours=cur.getColumnIndex(KEY_HOURS);
                    int iWebsite=cur.getColumnIndex(KEY_WEB);
                    int iType=cur.getColumnIndex(KEY_TYPE);
                Toast.makeText(DBUse.this, "Searching by Type", Toast.LENGTH_LONG).show();
                //  log.d("result",DBUse.getString(0));
                    for(cur.moveToFirst(); !cur.isAfterLast(); cur.moveToNext()){
                        result=result 
                                +cur.getString(iName) + " "
                                +cur.getString(iAddress) + " "
                                +cur.getString(iPhone) + " "
                                +cur.getString(iHours) + " "
                                +cur.getString(iWebsite) + " "
                                +cur.getString(iType) + " " + "\n";
                    Toast.makeText(DBUse.this, result, 30).show();
                };
                return;

                }

        };


    };

LogCat:

04-29 11:27:43.029: D/dalvikvm(8175): GC_FOR_ALLOC freed 177K, 12% free 2484K/2796K, paused 265ms, total 269ms
04-29 11:27:43.069: I/dalvikvm-heap(8175): Grow heap (frag case) to 3.138MB for 614416-byte allocation
04-29 11:27:43.209: D/dalvikvm(8175): GC_FOR_ALLOC freed 2K, 10% free 3082K/3400K, paused 140ms, total 140ms
04-29 11:27:43.451: D/dalvikvm(8175): GC_CONCURRENT freed <1K, 10% free 3082K/3400K, paused 5ms+99ms, total 243ms
04-29 11:27:44.099: D/dalvikvm(8175): GC_FOR_ALLOC freed <1K, 10% free 3081K/3400K, paused 30ms, total 30ms
04-29 11:27:44.119: I/dalvikvm-heap(8175): Grow heap (frag case) to 3.597MB for 483952-byte allocation
04-29 11:27:44.199: D/dalvikvm(8175): GC_CONCURRENT freed 0K, 9% free 3554K/3876K, paused 17ms+6ms, total 84ms
04-29 11:27:44.210: D/dalvikvm(8175): WAIT_FOR_CONCURRENT_GC blocked 7ms
04-29 11:27:44.639: D/gralloc_goldfish(8175): Emulator without GPU emulation detected.
04-29 11:27:48.739: D/AndroidRuntime(8175): Shutting down VM
04-29 11:27:48.739: W/dalvikvm(8175): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-29 11:27:48.790: E/AndroidRuntime(8175): FATAL EXCEPTION: main
04-29 11:27:48.790: E/AndroidRuntime(8175): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.think_bloomington/com.think_bloomington.DBUse}: java.lang.NullPointerException
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.os.Handler.dispatchMessage(Handler.java:99)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.os.Looper.loop(Looper.java:137)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.ActivityThread.main(ActivityThread.java:5041)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at java.lang.reflect.Method.invokeNative(Native Method)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at java.lang.reflect.Method.invoke(Method.java:511)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at dalvik.system.NativeStart.main(Native Method)
04-29 11:27:48.790: E/AndroidRuntime(8175): Caused by: java.lang.NullPointerException
04-29 11:27:48.790: E/AndroidRuntime(8175):     at com.think_bloomington.DBUse.onCreate(DBUse.java:41)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.Activity.performCreate(Activity.java:5104)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-29 11:27:48.790: E/AndroidRuntime(8175):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-29 11:27:48.790: E/AndroidRuntime(8175):     ... 11 more
4

2 に答える 2

1

NPE は、指している特定のボタンがアクティビティに含まれていないために生成されます。これは、誤ったアクティビティを指している可能性があるために発生します。

を使用してレイアウトファイルを修正するようにアクティビティをポイントします

setContentView(R.layout.activity_youractivity);
于 2013-04-29T11:44:05.033 に答える
0

このタイプのエラーは、

  1. xml に異なる ID があり、別の名前で t を呼び出しています。
  2. あなたが使用しているとき、ImageButtonまたはそれ以外のものではありませんButton。その後、ヌルポインタ例外が表示されます

基本的にあなたの xml をチェックしてください。そこで何か間違ったことをしています。

于 2013-04-29T11:43:44.383 に答える