import com.example.methanegaszonegeolocater.R;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;
//import com.google.android.gms.maps.model.MarkerOptions;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.graphics.Color;
import android.view.Menu;
import android.widget.EditText;
import android.widget.TextView;
import android.view.inputmethod.EditorInfo;
import android.widget.TextView;
import android.view.KeyEvent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setUpMapIfNeeded();
EditText editText = (EditText) findViewById(R.id.editText1);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
boolean handled = false;
if (actionId == EditorInfo.IME_ACTION_SEND) {
sendMessage();
handled = true;
}
return handled;
}
});
}
我已从Android开发者指南中删除了上述代码。我在Eclipse中显示了一些错误代码:
Multiple markers at this line
- The method setOnEditorActionListener(TextView.OnEditorActionListener) in the type
TextView is not applicable for the arguments (new OnEditorActionListener(){})
- OnEditorActionListener cannot be resolved
to a type
和
The method onEditorAction(TextView, int, KeyEvent) of type new OnEditorActionListener(){} must override or implement a supertype method
我正是在这一点上试图确定错误的原因。
答案 0 :(得分:1)
尝试更改行
editText.setOnEditorActionListener(new OnEditorActionListener() {
到
editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
或导入声明
import android.widget.TextView.OnEditorActionListener;
让我知道这是否有效。