Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 布局中的错误无法解决它_Java_Android_Eclipse - Fatal编程技术网

Java 布局中的错误无法解决它

Java 布局中的错误无法解决它,java,android,eclipse,Java,Android,Eclipse,我已经创建了四个选项卡,每个选项卡中都有listview。我一直在尝试使列表视图可单击,我使用的listview教程使用string.xml和R.array创建列表视图: 问题是,当我使用intent和McClickListener时,我会得到多个标记错误,如果我使用逗号括号和类主体标记,错误会四处移动,那么是语法问题还是代码的布局或位置问题 public class ll2 extends ListActivity { static final String[] teams = ne

我已经创建了四个选项卡,每个选项卡中都有listview。我一直在尝试使列表视图可单击,我使用的listview教程使用string.xml和R.array创建列表视图:

问题是,当我使用intent和McClickListener时,我会得到多个标记错误,如果我使用逗号括号和类主体标记,错误会四处移动,那么是语法问题还是代码的布局或位置问题

public class ll2 extends ListActivity {

    static final String[] teams = new String[] {"Accrington Stanley", "Aldershot", "Barnet", "Bradford City", "Burton Albion", "Bury", "Cheltenham Town", "Chesterfield", "Crewe Alexandra"};


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final String[] TEAMS = getResources().getStringArray(R.array.twoteams_array);
        setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, TEAMS));

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
              int position, long id) {

            public void onListItemClick(ListView, parent, View v, int position, long id);
            }

            if (position == "Braford City") {
                Intent intent = new Intent(this, Bradford.class);
                startActivity(intent);
            }

}
语法错误,请插入“}”以完成 类主体

如果我添加到完整的类主体中,我会在这里和其他地方遇到更多错误

我在这里得到这些错误:

static final String[] teams = new String[] {"Accrington Stanley", "Aldershot", "Barnet", "Bradford City", "Burton Albion", "Bury", "Cheltenham Town", "Chesterfield", "Crewe Alexandra"};
  public void onListItemClick(ListView, parent, View v, int position, long id); }
这条线上有多个标记 -令牌上的语法错误,构造位置错误 -语法错误,请插入“;”以完成LocalVariableDeclarationStatement -标记“,”上的语法错误;预期 -令牌“(”,=应为)上的语法错误 -令牌“,”上的语法错误;应为 -语法错误,请插入“}”以完成MethodBody -语法错误,插入“}”以完成类正文 -令牌“}”上出现语法错误,请删除此令牌 同样的问题在这里,我尝试了不同的组合,它给我的错误不断与此设置我有最少的错误量


非常感谢任何帮助

一切都很好,直到
SetonimclickListener
,一切都变得一团糟

 1  lv.setOnItemClickListener(new OnItemClickListener() {
 2      public void onItemClick(AdapterView<?> parent, View view, 
                                int position, long id) {
 3
 4      public void onListItemClick(ListView, parent, View v,
                                    int position, long id);
 5      }
 6
 7      if (position == "Braford City") {
 8          Intent intent = new Intent(this, Bradford.class);
 9          startActivity(intent);
10      }
11
12

非常感谢你,我会第一个承认嵌入了这一点,但在这个问题上的问题被你提出的代码弄乱了一点后,我终于成功了天才克里斯…天才的拼写是我的手机预测文本我的意思是9个问题
 1  lv.setOnItemClickListener(new OnItemClickListener() {
 2      public void onItemClick(AdapterView<?> parent, View view, 
                                int position, long id) {
 3
 4      public void onListItemClick(ListView, parent, View v,
                                    int position, long id);
 5      }
 6
 7      if (position == "Braford City") {
 8          Intent intent = new Intent(this, Bradford.class);
 9          startActivity(intent);
10      }
11
12
public void onListItemClick(ListView l, View v, int position, long id) {
    if (position == 3) {
        Intent intent = new Intent(this, Bradford.class);
        startActivity(intent);
    }
}