0
嗨我有两个类在android和一个类中我写了一个数组,我想在主类中访问它,但错误是给我,这里的“强制关闭”是我的代码访问数组与对象
package com.semanticnotion.DAO;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class DAO extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WordsDAO DAO = new WordsDAO(new String[]{"Arte","Arquitectura","Familia","Moda","Cotilleos","Cine","Libros","Historia","Pintura","Musica","Tendencies","Modernimso","Pop art","Masteialismo","realities","filosofia","moda","fotografia","religion"});
Button next = (Button) findViewById(R.id.Button01);
next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), WordsDAO.class);
startActivity(myIntent);
}
});
}
}
和第二类代码为
package com.semanticnotion.DAO;
public class WordsDAO {
String[] words = new String[]{"Arte","Arquitectura","Familia","Moda","Cotilleos","Cine","Libros","Historia","Pintura","Musica","Tendencies","Modernimso","Pop art","Masteialismo","realities","filosofia","moda","fotografia","religion"};
public WordsDAO(String[] words) {
this.words=words;
}
请任何一个可以告诉什么以及在此代码中的错误thaks
这是一个确切的重复http://stackoverflow.com/questions/3987349/accessing-array-with-object?不要这样做。 – 2010-10-21 13:43:01