0
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

我此时正试图确定错误的原因。

4

1 回答 1

1

换行试试

editText.setOnEditorActionListener(new OnEditorActionListener() {

editText.setOnEditorActionListener(new TextView.OnEditorActionListener() {

或导入语句

import android.widget.TextView.OnEditorActionListener;

让我知道这个是否奏效。

于 2013-06-10T05:10:41.673 回答