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