어느부분이 잘못되었는지 알수가 없습니다; 에러도 안뜨고;;
에뮬을 돌리니 화면은 뜨지가 않습니다. 목록까지도;;
어떤부분이 문제인가요?
--------소스부분--------------------------------------------------------------------------------------------
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ArrayList<String> alertsList = new ArrayList<String>();
String list1 = new String("aa");
alertsList.add(list1);
String list2 = new String("bb");
alertsList.add(list2);
String list3 = new String("cc");
alertsList.add(list3);
ArrayAdapter<String> listAD = new ArrayAdapter<String>(this, R.layout.main, alertsList);
ListView listView = (ListView)findViewById(R.id.alertsList);
listView.setAdapter(listAD);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
if(position == 0){
Intent intent = new Intent(test1.this, test2.class);
startActivity(intent);
Log.d("Intent Call","Call List" + position);
}
Log.d("Item Click Event", "Click" + position);
}
}
);
----------androidManifest.xml----------------------------------------------------------------------------------------
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".test1"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-sdk android:minSdkVersion="7" />
-----------------Main.xml------------------------------------------------------------------------------
<?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"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<ListView
android:id="@+id/alertsList"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<activity android:name="test2"/>
</activity>
manifest 에 기본 Activity 와 Intent 를 통해 보여줄 Activity 모두 등록해 놔야 하는걸로 알고 있습니다....
이부분 뒤에
<activity android:name=".test2" />
이런식으로 Activity를 등록해줘야 합니다.
만약 test2 Activity에서도 Intent를 사용한다면
test1처럼 안에 intent-filter를 설정해주어야 합니다.