안드로이드 개발 질문/답변
(글 수 45,052)
파일은 첨부했습니다.
GalleryContactsBook.java package androidbook.ch03.highrankwidget.contactsbook; public class GalleryContactsBook { private String Name; private String PhoneNumber; private String Email; public GalleryContactsBook (){} public GalleryContactsBook (String name, String phoneNumber, String email) { super(); Name = name; PhoneNumber = phoneNumber; Email = email; } public String getName() { return Name; } public void setName(String name) { Name = name; } public String getPhoneNumber() { return PhoneNumber; } public void setPhoneNumber(String phoneNumber) { PhoneNumber = phoneNumber; } public String getEmail() { return Email; } public void setEmail(String email) { Email = email; } }
ComplexGallery.java package androidbook.ch03.highrankwidget.gallery; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.Gallery; import android.widget.TextView; import androidbook.ch03.R; import androidbook.ch03.highrankwidget.contactsbook.GalleryContactsBook; public class ComplexGallery extends Activity { Gallery gallery; ArrayList<GalleryContactsBook> contacts; ContactsAdapter adapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.complex_gallery); gallery = (Gallery)findViewById(R.id.gallery); contacts = new ArrayList<GalleryContactsBook >(); contacts.add(new GalleryContactsBook ("내 사랑 아이유", "010-0000-0000","IU@gmail.com")); contacts.add(new GalleryContactsBook ("애프터스쿨", "010-1111-1111","AfterSchool@gmail.com")); contacts.add(new GalleryContactsBook ("소녀시대", "010-2222-2222","Girlgeneration@gmail.com")); contacts.add(new GalleryContactsBook ("카라", "010-3333-3333","TARA@gmail.com")); adapter = new ContactsAdapter(contacts); gallery.setAdapter(adapter); } class ContactsAdapter extends BaseAdapter { private ArrayList<GalleryContactsBook> object; public ContactsAdapter(ArrayList<GalleryContactsBook> object) { super(); this.object = object; } public int getCount() { return object.size(); } public Object getItem(int position) { return null; } public long getItemId(int position) { return 0; } public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if(convertView == null) { LayoutInflater inflater = LayoutInflater.from(ComplexGallery.this); convertView = inflater.inflate(R.layout.gallery_listrow,parent,false); holder = new ViewHolder(); holder.txtName = (TextView)convertView.findViewById(R.id.txt_name); holder.txtNumber = (TextView)convertView.findViewById(R.id.txt_number); convertView.setTag(holder); } else { holder = (ViewHolder)convertView.getTag(); } String name = object.get(position).getName(); String phonenumber = object.get(position).getPhoneNumber(); holder.txtName.setText(name); holder.txtNumber.setText(phonenumber); return convertView; } } static class ViewHolder { TextView txtName; TextView txtNumber; } }
위 두예제를 이용해서
주소록을 만들려고 하는데...
클릭했을때 따로 지정한 페이지가 뜰수있게 알려고하는데
방법을 잘 모르겠습니다.
이미지를 클릭했을때 뜨게 할려고 .setOnClickListener(new OnClickListener() {
를 사용했더니 이클립스에서는 구문상의 오류를 못찾지만
실제로 해당 액티비티 는 오류로 인해서 실행이 안됩니다.
어떻게 하는 게 좋을까요?