此行有多个标记 - 令牌上的语法错误&#34 ;;",预期

时间:2014-04-10 06:48:22

标签: java android

我发布了一些代码部分,它在旋转器声明结束时给出了错误。 令牌上的语法错误";"`

Syntax error on token ";", , expected

我无法解决该错误请帮助我。

提前谢谢。

public class UserEnquiryFormActivity extends Activity
{
    Button send,reset;
    EditText enquiry_c_name_editText1,enquiry_c_mob_no_editText2,enquiry_c_emailid_editText3;
    Spinner enquiry_spinner1,enquiry_spinner2,enquiry_spinner3,enquiry_spinner4;


    SQLiteDatabase = new DataBaseHelper (this);


    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_user_enquiry_form);


        // get Instance  of Database Adapter
        final DataBaseHelper dbhelper = new DataBaseHelper(this);



         // Get Refferences of Views
        enquiry_c_name_editText1=(EditText)findViewById(R.id.enquiry_form_editText1);
        enquiry_c_mob_no_editText2=(EditText)findViewById(R.id.enquiry_form_editText2);
        enquiry_c_emailid_editText3=(EditText)findViewById(R.id.enquiry_form_editText3);

        enquiry_spinner1=(Spinner)findViewById(R.id.enquiry_area_type_spinner1);
        enquiry_spinner2=(Spinner)findViewById(R.id.enquiry_contract_type_spinner2);
        enquiry_spinner3=(Spinner)findViewById(R.id.enquiry_house_type_spinner3);
        enquiry_spinner4=(Spinner)findViewById(R.id.enquiry_location_spinner4);

        send=(Button)findViewById(R.id.user_enq_btn1);
        reset=(Button)findViewById(R.id.user_enq_btn2);


        send.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {

                String customer_name= enquiry_c_name_editText1.getText().toString();
                String customer_mob_no= enquiry_c_mob_no_editText2.getText().toString();
                String customer_emailid= enquiry_c_emailid_editText3.getText().toString();


                String area_type=enquiry_spinner1.toString();
                String contaract_type=enquiry_spinner2.toString();
                String house_type=enquiry_spinner3.toString();
                String area=enquiry_spinner4.toString();


                // check if any of the fields are vaccant
                 if(customer_name.equals("")|| customer_mob_no.equals("")|| customer_emailid.equals("")||area_type.equals("") || contaract_type.equals("") || house_type.equals("") || area.equals(""))
                 {
                     Toast.makeText(getApplicationContext(), "Field Vaccant", Toast.LENGTH_LONG).show();
                     return;
                 }


                 else
                 {
                        // Save the Data in Database
                        dbhelper.insertEnquiry(customer_name, customer_mob_no,customer_emailid ,area_type, contaract_type,house_type,area);
                        Toast.makeText(getApplicationContext(), "Information Send Successfully ", Toast.LENGTH_LONG).show();
                 }


                Intent main2=new Intent(UserEnquiryFormActivity.this,HomeActivity.class);
                startActivity(main2);

            }
        });


        reset.setOnClickListener(new View.OnClickListener()
        {
            public void onClick(View v)
            {
                reset();
            }
        });


        // Show the Up button in the action bar.
        setupActionBar();
    }


    void reset()
    {
        enquiry_c_name_editText1.setText("");
        enquiry_c_mob_no_editText2.setText("");
        enquiry_c_emailid_editText3.setText("");
        enquiry_spinner1.setId(0);
        enquiry_spinner2.setId(0);
        enquiry_spinner3.setId(0);
        enquiry_spinner4.setId(0);
    }

    /**
     * Set up the {@link android.app.ActionBar}.
     */
    private void setupActionBar() 
    {

        getActionBar().setDisplayHomeAsUpEnabled(true);

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) 
    {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.user_enquiry_form, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) 
    {
        switch (item.getItemId()) 
        {
            case android.R.id.home:
            // This ID represents the Home or Up button. In the case of this
            // activity, the Up button is shown. Use NavUtils to allow users
            // to navigate up one level in the application structure. For
            // more details, see the Navigation pattern on Android Design:
            //
            // http://developer.android.com/design/patterns/navigation.html#up-vs-back
            //
            NavUtils.navigateUpFromSameTask(this);
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

1 个答案:

答案 0 :(得分:1)

它是具有语法错误的微调器声明的下一行:

SQLiteDatabase = new DataBaseHelper (this);

您忘记声明变量名称,例如

SQLiteDatabase db = new DataBaseHelper (this);