안드로이드 개발 질문/답변
(글 수 45,052)
간단하게 ListView 를 만들어서 선택이 되면 다른 Activity를 실행하고자 하는데
다른 Activity에서 xml 간단히 만든것을 setContentView 로 지정을 해주고
실행을 하니 계속 죽기만 하네요...
맞게 한거 같은데..혹 빠뜨린게 있을까요
test_list.xml
다른 Activity에서 xml 간단히 만든것을 setContentView 로 지정을 해주고
실행을 하니 계속 죽기만 하네요...
맞게 한거 같은데..혹 빠뜨린게 있을까요
package com.test.android;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class test_android extends ListActivity {
private final String[] mStrings = {"t1", "t2"};
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, mStrings));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Intent intent = new Intent(this, Test2_Android.class);
startActivity(intent);
}
}
package com.test.android;
import android.app.ListActivity;
import android.os.Bundle;
import com.test.android.R;
public class Test2_Android extends ListActivity{
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.test_list);
}
}
test_list.xml
<?xml version="1.0" encoding="utf-8"?> <ListView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="wrap_content" android:layout_height="wrap_content"> </ListView>
2010.08.27 11:26:06
setListAdapter 밑에
setContentView(R.layout.main); 추가를 해도 동일하네요....ㅠㅠ
뭔가 설치가 잘못된것인지......
setContentView(R.layout.main); 추가를 해도 동일하네요....ㅠㅠ
뭔가 설치가 잘못된것인지......
2010.08.27 13:23:30
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<ListView
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>



