我在“活动”中的所有地方都使用Listview和Spinner,

如果我设置导入

import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;


我得到错误

 Caused by: java.lang.ClassCastException: org.holoeverywhere.widget.Spinner cannot be cast to android.widget.Spinner


如果我设置为导入

import org.holoeverywhere.widget.AdapterView;
import org.holoeverywhere.widget.ArrayAdapter;
import android.widget.ListView;
import org.holoeverywhere.widget.Spinner;
import org.holoeverywhere.widget.AdapterView.OnItemClickListener;
import org.holoeverywhere.widget.AdapterView.OnItemSelectedListener;




 listview.setOnItemClickListener(new OnItemClickListener() {

                public void onItemClick(AdapterView<?> arg0, View arg1,
                        int arg2, long arg3) {
                    // TODO Auto-generated method stub
                }
            });


我出错了

the method setonitemselectedlistener(adapterview.onitemselectedlistener) in the type adapterview <ListAdapter> is not applicable for the arguments


如何解决?

最佳答案

问题是您需要使用两个具有相同名称的类。您将需要使用以下内容:

listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() {

  public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    // Your code here
  }
});

关于android - Listview和Spinner Holloeverwherewhere冲突?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22454647/

10-12 04:11