這是錯誤我得到爲什麼會出現「錯誤:(57,21)錯誤:到達文件的末尾,而解析」
Error:(57, 21) error: reached end of file while parsing
而使用這個代碼
package com.bilalbenzine.hotel;
import android.content.ContentValues;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.PersistableBundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.appindexing.Action;
import com.google.android.gms.appindexing.AppIndex;
import com.google.android.gms.appindexing.Thing;
import com.google.android.gms.common.api.GoogleApiClient;
import io.realm.Realm;
/**
* Created by hmito on 04/04/2017.
*/
public class add_hotel extends AppCompatActivity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.add_hotel);
final EditText name=(EditText)findViewById(R.id.name_hotel);
final EditText place=(EditText)findViewById(R.id.place_hotel);
final EditText stars=(EditText)findViewById(R.id.stars);
final EditText description=(EditText)findViewById(R.id.description);
final Button addhotel=(Button)findViewById(R.id.btn_add_hotel);
addhotel.hasOnClickListeners(new View.OnClickListener(){
@Override
public void onClick(View view) {
hotel hotel = new hotel();
hotel.setName_hotel(name.getText().toString());
hotel.setName_hotel(place.getText().toString());
hotel.setName_hotel(stars.getText().toString());
hotel.setName_hotel(description.getText().toString());
Realm realm = Realm.getInstance(getApplicationContext());
realm.beginTransaction();
realm.copyToRealmOrUpdate(hotel);
realm.commitTransaction();
Toast.makeText(add_hotel.this, "The hotel has been successfully added", Toast.LENGTH_SHORT).show();
}
);
}
}
修復你的間距,你的問題會很明顯 - 你的{}和()對不匹配。 –
您可以使用Android Studio來格式化您的代碼。請在發佈您的問題之前做到這一點 –
數字匹配 –