需要帮助修复我的项目的各种错误

时间:2012-04-24 17:38:52

标签: java android

第18行:语法错误,输入}以完成classBody。

第33/38行:令牌上的语法错误,而是预期的注释名称。

第416行:此行的多个标记      - 语法错误,插入“EnumBody”      完成EnumDeclaration      - 语法错误,插入“)”到      完整的修饰符      - 语法错误,插入“枚举      标识符“完成EnumHeader      - 语法错误,插入“)”到      完整表达      - 语法错误,插入“}”      完整的ClassBody      - 语法错误,插入“}”      完成MethodBody      - 语法错误,插入“;”至      完整声明

以上,我有几个错误,我不知道如何解决。我也试图看看我的代码是否起作用。我正在尝试从相反类别的输入中获取名称/数字的输出,并将其放入textView“显示”。

我的代码:(或我的代码line numbers

package walmart.namespace;



import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class WalmartActivity extends Activity {
    /** Called when the activity is first created. */

    EditText department;
    EditText name;
    Button search;
    String display;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        department = (EditText) findViewById(getResources().getIdentifier("etNum", "id", getPackageName()));
        name = (EditText) findViewById(getResources().getIdentifier("etName", "id", getPackageName()));
        search = (Button) findViewById(getResources().getIdentifier("btnSearch", "id", getPackageName()));
        final String Display;

        department.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    et.setText("");
                }
       name.setOnClickListener(new View.OnClickListener() {

                        public void onClick(View v) {
                            et.setText("");
                        }
        search.setOnClickListener(new View.OnClickListener() {

            public void onClick(View v) {


                switch (department) {
                case 1: display = "food";
                case 2: display = "Health and Beauty Aids";
                case 3: display = "Stationary and Books";
                case 4: display = "Paper Goods";
                case 5: display = "Home Entertainment";
                case 6: display = "Cameras and Film";
                case 7: display = "Toys";
                case 8: display = "Pets and Pet Supplies";
                case 9: display = "Sporting Goods";
                case 10:display = "Automotive";
                case 11:display = "Hardware";
                case 12: display = "Paint and Accessories";
                case 13: display = "Household Chemicals";
                case 14: display = "Housewares";
                case 15: display = "Appliances";
                case 16: display = "Lawn and Garden";
                case 17: display = "Home Furnishings";
                case 18: display = "Seasonal";
                case 19: display = "Fabrics and Crafts";
                case 20: display = "Domestic Goods";
                case 21: display = "Curtains";
                case 22: display = "Bedding";
                case 23: display = "Mens";
                case 24: display = "Boys";
                case 25: display = "Shoes";
                case 26: display = "Infants and Toddlers";
                case 27: display = "Ladies Socks";
                case 28: display = "Nylon Hosiery";
                case 29: display = "Lingerie";
                case 30: display = "Foundations";
                case 31: display = "Handbags and Accessories";
                case 32: display = "Jewlery";
                case 33: display = "Girls";
                case 34: display = "Ladies";
                case 36: display = "Outerwear";
                case 39: display = "Food Services";
                case 40: display = "Pharmacy";
                case 46: display = "Cosmetics";
                case 49: display = "Optical";
                case 56: display = "Horticulture";
                case 58: display = "Income";
                case 77: display = "Large Appliances";
                case 80: display = "Service Deli";
                case 81: display = "Bread";
                case 82: display = "Impulse Buys";
                case 83: display = "Seafood";
                case 84: display = "Floral";
                case 85: display = "1 Hour Photo";
                case 86: display = "Fresh Flowers and Balloons";
                case 87: display = "Wireless";
                case 89: display = "Travel Center";
                case 90: display = "Dairy";
                case 91: display = "Frozen Foods";
                case 92: display = "Grocery";
                case 93: display = "Meats";
                case 94: display = "Produce";
                case 95: display = "DSD Grocery";
                case 96: display = "Liqour";
                case 97: display = "Processed Meats";
                case 98: display = "Bakery";
                case 99: display = "Store Use";
                }
                {
                if (name.equals("Electronics"))
                {
                    display = "5";
                }
                else if (name.equals("candy"))
                {
                    display=("1");
                }
                else if (name.equals("Tobacco"))
                {
                    display=("1");
                }
                else if (name.equals("Makeup"))
                {
                    display=("2");
                }
                else if (name.equals("Stationary"))
                {
                    display=("3");
                }
                else if (name == "Books")
                {
                    display=("3");
                }
                else if (name == "Napkins")
                {
                    display=("4");
                }
                else if (name == "Paper Plates")
                {
                    display=("4");
                }
                else if (name == "Paper")
                {
                    display=("4");
                }
                else if (name == "Video Games")
                {
                    display=("5");
                }
                else if (name == "Movies")
                {
                    display=("5");
                }
                else if (name == "Cameras")
                {
                    display=("6");
                }
                else if (name == "Film")
                {
                    display=("6");
                }
                else if (name == "Photo")
                {
                    display=("6");
                }
                else if (name == "Toys")
                {
                    display=("7");
                }
                else if (name == "Fishing Rods")
                {
                    display=("9");
                }
                else if (name == "Sporting Equipment")
                {
                    display=("9");
                }
                else if (name == "Sporting Goods")
                {
                    display=("9");
                }
                else if (name == "Car Stereos")
                {
                    display=("10");
                }
                else if (name == "Automotive")
                {
                    display=("10");
                }
                else if (name == "Tools")
                {
                    display=("11");
                }
                else if (name == "Heaters")
                {
                    display=("11");
                }
                else if (name == "Fans")
                {
                    display=("11");
                }
                else if (name == "Hardware")
                {
                    display=("11");
                }
                else if (name == "Paint")
                {
                    display=("12");
                }
                else if (name == "Bleach")
                {
                    display=("13");
                }
                else if (name == "Ammonia")
                {
                    display=("13");
                }
                else if (name == "Chemicals")
                {
                    display=("13");
                }
                else if (name == "Towels")
                {
                    display=("14");
                }
                else if (name == "Kitchen Accessories")
                {
                    display=("14");
                }
                else if (name == "Towels")
                {
                    display=("14");
                }
                else if (name == "Appliances")
                {
                    display=("15");
                }
                else if (name == "Plants")
                {
                    display=("16");
                }
                else if (name == "Grills")
                {
                    display=("16");
                }
                else if (name == "Lawn & Garden")
                {
                    display=("16");
                }
                else if (name == "Furniture")
                {
                    display=("17");
                }
                else if (name == "Seasonal")
                {
                    display=("18");
                }
                else if (name == "Fabrics and Crafts")
                {
                    display=("19");
                }
                else if (name == "Domestics")
                {
                    display=("20");
                }
                else if (name == "Curtains")
                {
                    display=("21");
                }
                else if (name == "Bedding")
                {
                    display=("22");
                }
                else if (name == "Mens")
                {
                    display=("23");
                }
                else if (name == "Boys")
                {
                    display=("24");
                }
                else if (name == "Shoes")
                {
                    display=("25");
                }
                else if (name == "Infants")
                {
                    display=("26");
                }
                else if (name == "Ladies Socks")
                {
                    display=("27");
                }
                else if (name == "Pantyhose")
                {
                    display=("28");
                }
                else if (name == "Lingerie")
                {
                    display=("29");
                }
                else if (name == "Purses")
                {
                    display=("31");
                }
                else if (name == "Handbags")
                {
                    display=("31");
                }
                else if (name == "Jewelry")
                {
                    display=("32");
                }
                else if (name == "Girls")
                {
                    display=("33");
                }
                else if (name == "Maternity")
                {
                    display=("35");
                }
                else if (name == "Outerwear")
                {
                    display=("36");
                }

                else if (name == "Pharmacy")
                {
                    display=("40");

                }
                else if (name == "Cosmetics")
                {
                    display=("46");
                }
                else if (name == "Optical")
                {
                    display=("49");
                }

                else if (name == "Large Appliances")
                {
                    display=("77");
                }
                else if (name == "Deli")
                {
                    display=("80");
                }
                else if (name == "Bread")
                {
                    display=("81");
                }
                else if (name == "Seafood")
                {
                    display=("83");
                }
                else if (name == "Floral")
                {
                    display=("84");
                }
                else if (name == "One Hour Photo")
                {
                    display=("85");
                }
                else if (name == "Fresh Flowers")
                {
                    display=("86");

                }
                else if (name == "Cell Phones")
                {
                    display=("87");
                }
                else if (name == "Travel Center")
                {
                    display=("89");
                }
                else if (name == "Luggage")
                {
                    display=("89");
                }
                else if (name == "Dairy")
                {
                    display=("90");
                }
                else if (name == "Milk")
                {
                    display=("90");
                }
                else if (name == "Frozen Foods")
                {
                    display=("91");
                }
                else if (name == "Frozen")
                {
                    display=("91");
                }
                else if (name == "Grocery")
                {
                    display=("92");
                }
                else if (name == "Meats")
                {
                    display=("93");
                }
                else if (name == "Produce")
                {
                    display=("94");
                }
                else if (name == "Liquor")
                {
                    display=("96");
                }
                else if (name == "Bakery")
                {
                    display=("98");
                }

            }

1 个答案:

答案 0 :(得分:3)

我已在此修复了您的格式问题:http://pastebin.com/YijryAPK 请注意,由于错误使用Java,错误仍然存​​在。除了switchint之外,您无法使用enum。此外,当您在底部设置两个OnClickListeners时,您没有定义名为“et”的视图。