안드로이드 개발 질문/답변
(글 수 45,052)
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.intro);
string TextView;
TextView widget32;
Button widget33;
widget32 = (TextView)findViewById(R.id.widget32);
widget33 = (Button)findViewById(R.id.widget33);
widget33.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
Intent i = new Intent(P2.this , P10.class);
startActivity(i);//i
finish();
}
});
/* try{
widget32.setText(readtest());
}catch(IOException e){}
setContentView(widget32);
}
요
private String readtest() throws IOException {
String test;
FileInputStream textfis = new FileInputStream("/Text/intro.txt");
BufferedInputStream textbis = new BufferedInputStream(textfis);
byte[] buffer = new byte[1024];
textbis.read(buffer);
test = new String(buffer);
return test ;*/
}
main에서 intent 통신으로 이쪽 클래스로 넘어오는 소스후에
저렇게 textview 가 assets폴더 의 text폴더 안에 intro.txt를 읽어오는 과정을
주석처리하고 하면 아무 오류 없이 잘 작동하는데
주석처리를 풀고 하면 저 클래스로 이동할때 예상치못한 오류라 하면서 종료를 합니다.
리스트뷰나 그런거 추가 하지 않았고요.
그냥 absolutelayout 안에 위에 텍스트뷰가 있고 그 바로 밑에 버튼이 하나 있는 구조 인데
문제가 있나요? 리스트 뷰안에 텍스트를 넣고 조정해야 하나요??
콘솔에는 아무것도 뜨질 않습니다;
2011.07.14 11:29:49
음;; 제 생각은
프로젝트에 assets 폴더 안에 text 폴더 를 만들고 그 안에 intor.txt를 넣으셧단거 같은데
FileInputStream textfis = new FileInputStream("/Text/intro.txt");
이렇게 적으신건 assets 의 Text 폴더를 찾아가는게 아니라
실제 핸드폰 메모리의 text폴더를 찾아가는거라 파일 익셉션이 발생하는것같네요.
assets 데이터를 가져오는 방법은 getResource() 통해서 가져온다고 알고있어요.
assets 관련 해서 찾아보시는게 좋을듯 함여




로그캣 확인해보세요. string TextView?