Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Type mismatch: cannot convert from java.lang.String to String

I don't understand why I got this error!

public static class RoomsArrayAdapter<String> extends ArrayAdapter<String>{
****
private String rmName;
    private ArrayList<String> st_list = new ArrayList<String>();

public View getView(int position, View convertView, ViewGroup parent){                      
        View rowView = convertView; 
        LayoutInflater inflater = (LayoutInflater) raaContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        rowView = inflater.inflate(R.layout.room_layout, parent, false);
        rmName = st_list.get(position).toString();

error in rmName = st_list.get(position).toString();

There is my imports:

import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.app.AlertDialog;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.DialogInterface.OnClickListener;
import android.content.pm.PackageManager;
import android.graphics.Color;
import android.provider.Settings;
import android.util.Log;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.inputmethod.CompletionInfo;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import android.R.color;

First time I was had error after add onTextChanged method to AutoCompleteTextView in getView() of my ArrayAdapter. I try to restart Eclipse, but it's not help me.

like image 505
GIKO Avatar asked Feb 14 '23 12:02

GIKO


1 Answers

The

public static class RoomsArrayAdapter<String> extends ArrayAdapter<String>{

should read

public static class RoomsArrayAdapter extends ArrayAdapter<String>{

Your current code creates a generic type parameter called String, which you don't need and whose name clashes with java.lang.String.

like image 55
NPE Avatar answered Feb 17 '23 01:02

NPE