우편번호 불러오기 기초작업
- /layout/dialog_post.xml 생성
12345678910111213141516171819202122232425262728293031323334353637383940414243444546<?xml version="1.0" encoding="utf-8"?><LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/LinearLayout1"android:layout_width="350dp"android:layout_height="600dp"android:orientation="vertical"><TextViewandroid:id="@+id/lblPost"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="@string/dialog_post_text_label" /><LinearLayoutandroid:id="@+id/linearSearch"android:layout_width="match_parent"android:layout_height="wrap_content"><EditTextandroid:id="@+id/txtRoad"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="3"android:ems="10"android:hint="@string/dialog_post_hint_road"><requestFocus /></EditText><Buttonandroid:id="@+id/btnSearch"android:layout_width="0dp"android:layout_height="wrap_content"android:layout_weight="1"android:text="@string/dialog_post_button_search" /></LinearLayout><ListViewandroid:id="@+id/lstAddr"android:layout_width="match_parent"android:layout_height="wrap_content"/></LinearLayout> - /layout/dialog_post_listitem.xml 생성
12345678910111213141516171819202122<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="match_parent"android:orientation="horizontal"android:padding="2dp"><TextViewandroid:id="@+id/txtPost"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:padding="2dp" /><TextViewandroid:id="@+id/txtAddr"android:layout_width="match_parent"android:layout_height="wrap_content"android:layout_weight="4"android:maxLines="3"android:padding="2dp" /></LinearLayout> - PostDTO.java 생성
1234567891011public class PostDTO {public int _id;public String post = "";public String sido = "";public String sigu = "";public String eupm = "";public String road = "";public String even = "";public String addr = "";} - PostAdapter.java 생성
123456789101112131415161718192021222324252627282930313233343536373839404142public class PostAdapter extends BaseAdapter {Context context;ArrayList<PostDTO> arList;LayoutInflater mInflater;PostAdapter(Context context, ArrayList<PostDTO> arList) {this.context = context;this.arList = arList;mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);}@Overridepublic View getView(int position, View convertView, ViewGroup parent) {View row = mInflater.inflate(R.layout.dialog_post_listitem, parent, false);final String post = arList.get(position).post;final String addr = arList.get(position).addr;((TextView) row.findViewById(R.id.txtPost)).setText(post);((TextView) row.findViewById(R.id.txtAddr)).setText(addr);return row;}@Overridepublic int getCount() {// TODO Auto-generated method stubreturn arList.size();}@Overridepublic Object getItem(int position) {// TODO Auto-generated method stubreturn arList.get(position);}@Overridepublic long getItemId(int position) {// TODO Auto-generated method stubreturn position;}} - DialogPostListener.java 생성
1234public interface DialogPostListener {public void onPositiveClicked(String post, String addr1);public void onNegativeClicked();} - FragRegister.java 수정(다이얼로그 이벤트리스너 변수 생성)
12345678910111213//다이얼로그 이벤트 리스터 변수 생성private DialogPostListener dlg_onClickListener = new DialogPostListener(){@Overridepublic void onPositiveClicked(String post, String addr1) {((EditText)getView().findViewById(R.id.txtPost)).setText(post);((EditText)getView().findViewById(R.id.txtAddr1)).setText(addr1);}@Overridepublic void onNegativeClicked() {}};