코드에서 새 Layout

1246 단어 layout
1. layout 선언
LinearLayout linearLayoutMain = new LinearLayout(this);
		linearLayoutMain.setLayoutParams(new LayoutParams(
				LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

 
2. listview 넣기
ListView listView = new ListView(this);
listView.setFadingEdgeLength(0);
listView.setAdapter(openDialogAdp);
linearLayoutMain.addView(listView);

 
3. 팝업에 AlertDialog를 사용한 응답
editDialog = new AlertDialog.Builder(this).setView(linearLayoutMain)
				.create();
		editDialog.setCanceledOnTouchOutside(false);
		
	
		listView.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				// arg2 is the position you clicked
				String number = extracts.get(arg2).getNumber();
				Intent data = new Intent();
				data.putExtra(CONTACT_DETAILS_RESULT_NUMBER, number);
				setResult(PICK_CONTACT_REQUEST, data);
				finish();

				editDialog.cancel();
			}
		});

		editDialog.show();

 

좋은 웹페이지 즐겨찾기