public class List1 extends ListActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlist);
ArrayList<Person> m_orders = new ArrayList<Person>();
Person p1 = new Person("삼악산", "강원 춘천시 서면 덕두원리 118-6");
Person p2 = new Person("남이섬", "강원 춘천시 남산면 방하리 198");
Person p3 = new Person("소양댐", "강원도 춘천시 신북읍 천전리 산4번지");
Person p4 = new Person("의암댐", "강원 춘천시 신동면(新東面) 의암리");
Person p5 = new Person("용화산", "강원 춘천시 사북면 고성리 산102 외14 ");
Person p6 = new Person("구곡폭포", "강원 춘천시 남산면 강촌1리 432번지");
Person p7 = new Person("청평사", "강원도 춘천시 북산면 청평리 674");
Person p8 = new Person("봉의산성", "강원 춘천시 소양로 1가 산1-1");
m_orders.add(p1);
m_orders.add(p2);
m_orders.add(p3);
m_orders.add(p4);
m_orders.add(p5);
m_orders.add(p6);
m_orders.add(p7);
m_orders.add(p8);
PersonAdapter m_adapter = new PersonAdapter(this, R.layout.row1, m_orders);
setListAdapter(m_adapter);
ListView listView = (ListView)findViewById(R.id.list);
listView.setAdapter((ListAdapter) m_orders);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
if(position == 0){
Intent a= new Intent(List1.this,Chug1.class);
startActivity(a);
}
}
});
}
private class PersonAdapter extends ArrayAdapter<Person> {
private ArrayList<Person> items;
public PersonAdapter(Context context, int textViewResourceId, ArrayList<Person> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
Person p = items.get(position);
if (p != null) {
TextView tt = (TextView) v.findViewById(R.id.toptext);
TextView bt = (TextView) v.findViewById(R.id.bottomtext);
if (tt != null){
tt.setText(p.getName());
}
if(bt != null){
bt.setText("주소: "+ p.getNumber());
}
}
return v;
}
}
class Person {
private String Name;
private String Number;
public Person(String _Name, String _Number){
this.Name = _Name;
this.Number = _Number;
}
public String getName() {
return Name;
}
public String getNumber() {
return Number;
}
}
}
이게 리스트 뷰 클래스인데 ListView listView = (ListView)findViewById(R.id.list);
listView.setAdapter((ListAdapter) m_orders);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
if(position == 0){
Intent a= new Intent(List1.this,Chug1.class);
startActivity(a);
이 부분에서 chug1클래스로 넘기려고 하는데 에러는 안나는데 작동이 안되네요 ㅜㅜ 메인 클래스는 bacground 클래스이고 이거에서 option 클래스에서 리스트뷰 클래스에서 chug1클래스 까지 연결 시킬려고 하는데 opion 클래스에서 리스트뷰 클래스로 이어지는 부분이
작동이 안되네요 ㅜㅜ 원래는 되다가 저거 추가하니 안되네요 ㅜㅜ
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidside.background"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Background"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Option"
android:label="@string/app_name"></activity>
<activity android:name=".List1"
android:label="@string/app_name">
<activity android:name=".Chug1"
android:label="@string/app_name"></activity>
</activity>
<activity android:name=".List2"
android:label="@string/app_name"></activity>
</application>
</manifest>
이건 manifest 부분입니다.
이거 땜에 미치겠습니다 ㅜㅜ 딴것도 못하고 ㅜㅜ 도와주세요 ㅠㅠㅠ
<activity android:name=".List1"
android:label="@string/app_name">
</activity> <============== 추가
<activity android:name=".Chug1"
android:label="@string/app_name"></activity>
</activity> <===============삭제
android:label="@string/app_name"></activity>
<activity android:name=".List1"
android:label="@string/app_name"></activity>
<activity android:name=".Chug1"
android:label="@string/app_name"></activity>
<activity android:name=".List2"
android:label="@string/app_name"></activity>
이렇게 해줬는데도 에러가 나네요 ㅜㅜ option클래스에서 list1 으로 넘어가는 부분에서 동작이 안되요
ListView listView = (ListView)findViewById(R.id.list);
listView.setAdapter((ListAdapter) m_orders);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
if(position == 0){
call_intent();
}
.
.
.
public void call_intent(){
Intent a= new Intent(List1.this,Chug1.class);
startActivity(a);
}
이렇게 별도 함수로 빼 보시면 어떤가요?
public class List1 extends ListActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlist);
ArrayList<Person> m_orders = new ArrayList<Person>();
Person p1 = new Person("삼악산", "강원 춘천시 서면 덕두원리 118-6");
Person p2 = new Person("남이섬", "강원 춘천시 남산면 방하리 198");
Person p3 = new Person("소양댐", "강원도 춘천시 신북읍 천전리 산4번지");
Person p4 = new Person("의암댐", "강원 춘천시 신동면(新東面) 의암리");
Person p5 = new Person("용화산", "강원 춘천시 사북면 고성리 산102 외14 ");
Person p6 = new Person("구곡폭포", "강원 춘천시 남산면 강촌1리 432번지");
Person p7 = new Person("청평사", "강원도 춘천시 북산면 청평리 674");
Person p8 = new Person("봉의산성", "강원 춘천시 소양로 1가 산1-1");
m_orders.add(p1);
m_orders.add(p2);
m_orders.add(p3);
m_orders.add(p4);
m_orders.add(p5);
m_orders.add(p6);
m_orders.add(p7);
m_orders.add(p8);
PersonAdapter m_adapter = new PersonAdapter(this, R.layout.row1, m_orders);
setListAdapter(m_adapter);
ListView listView = (ListView)findViewById(R.id.list);
listView.setAdapter((ListAdapter) m_orders);
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view, int position, long id){
if(position == 0){
call_intent();
}
}
});
}
public void call_intent(){
Intent a= new Intent(List1.this,Chug1.class);
startActivity(a);
}
private class PersonAdapter extends ArrayAdapter<Person> {
private ArrayList<Person> items;
public PersonAdapter(Context context, int textViewResourceId, ArrayList<Person> items) {
super(context, textViewResourceId, items);
this.items = items;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
if (v == null) {
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.row, null);
}
Person p = items.get(position);
if (p != null) {
TextView tt = (TextView) v.findViewById(R.id.toptext);
TextView bt = (TextView) v.findViewById(R.id.bottomtext);
if (tt != null){
tt.setText(p.getName());
}
if(bt != null){
bt.setText("주소: "+ p.getNumber());
}
}
return v;
}
}
class Person {
private String Name;
private String Number;
public Person(String _Name, String _Number){
this.Name = _Name;
this.Number = _Number;
}
public String getName() {
return Name;
}
public String getNumber() {
return Number;
}
}
}
이렇게 바꾸어 줬는데도 안되네요 ㅜㅜ 에러는 안뜨는데 예상치 않게 중지되었습니다. 이렇게 뜨네요 ㅜㅜ 왜안되는지 모르겠네요...<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.androidside.background"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".Background"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name=".Option"
android:label="@string/app_name"></activity>
<activity android:name=".List1"
android:label="@string/app_name"></activity>
<activity android:name=".Chug1"
android:label="@string/app_name"></activity>
<activity android:name=".List2"
android:label="@string/app_name"></activity>
</application>
</manifest> 매니페스트에도 등록해줬는데도;;; option - list1- chug1 이렇게 인텐트 시키는건데 option - list1에서 안된다고 나오네요..
list1에 인텐트 하기전엔 그래도 이건 됬었는데 이것도 안되요.




<activity android:name=".List1"
android:label="@string/app_name">
<activity android:name=".Chug1"
android:label="@string/app_name"></activity>
</activity>
이렇게 해둬도 xml이 이상하다거나 액티비티 못찾았다는 에러가 안나나보군요 싱기싱기. '-'