확인란을 사용하여 multiselect 회 전자를 만들려고 시도하지만 그 방법을 알지 못해서 altenative 드롭 다운 multiselect popupdialog를 수행하는 방법을 생각해 냈습니다. 나는 팝업 창을 보여줄 수 있었지만 내 문제는 .. 그림에서 볼 수 있듯이 팝업 창은 정보 유형 상자에 정렬되어 있지 않습니다 ... 저를 도와 줄 수 있습니까? 여기 android의 팝업 드롭 다운 대화 상자의 크기를 조정하는 방법
는 popupInformationType.xml<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/PopUpViewInformationType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical">
<ListView
android:id="@+DropDownList/dropDownListInfoType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#d3d3d3"
android:cacheColorHint="@color/cachecolorhint"
android:divider="#000"
android:dividerHeight="0.5dp" >
</ListView>
</LinearLayout>
에 내 코드이며, 여기 내 dro_down_list_infotype.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="fill_parent">
<CheckBox
android:id="@+DropDownList/checkboxInfoType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:button="@drawable/selector_checkbox"
android:layout_marginLeft="10dp" />
<TextView
android:id="@+DropDownList/SelectOptionInfoType"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#000"
android:layout_gravity="center_vertical"/>
</LinearLayout>
을의 코드이며, 여기에 내 코드의 일부입니다 팝업창을 호출하는 MainActivity
private void initiatePopUpInfoType(ArrayList<String> informationTypes, TextView tv_InformationType){
LayoutInflater inflater = (LayoutInflater)IreportMain.this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//get the pop-up window i.e. drop-down layout
LinearLayout layoutInfoType = (LinearLayout)inflater.inflate(R.layout.popup_informationtype, (ViewGroup)findViewById(R.id.PopUpViewInformationType));
//get the view to which drop-down layout is to be anchored
RelativeLayout layout2 = (RelativeLayout)findViewById(R.id.relativeLayout2);
pwInfoType = new PopupWindow(layoutInfoType, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT, true);
pwInfoType.setBackgroundDrawable(new BitmapDrawable());
pwInfoType.setTouchable(true);
//let pop-up be informed about touch events outside its window. This should be done before setting the content of pop-up
pwInfoType.setOutsideTouchable(true);
pwInfoType.setHeight(LayoutParams.WRAP_CONTENT);
//dismiss the pop-up i.e. drop-down when touched anywhere outside the pop-up
pwInfoType.setTouchInterceptor(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
if (event.getAction() == MotionEvent.ACTION_OUTSIDE) {
pwInfoType.dismiss();
return true;
}
return false;
}
});
//provide the source layout for drop-down
pwInfoType.setContentView(layoutInfoType);
//anchor the drop-down to bottom-left corner of 'layout2'
pwInfoType.showAsDropDown(layout2);
//populate the drop-down list
final ListView listInfoType = (ListView) layoutInfoType.findViewById(R.DropDownList.dropDownListInfoType);
InfoTypeListAdapter adapter = new InfoTypeListAdapter(this, informationTypes, tv_InformationType);
listInfoType.setAdapter(adapter);
}
U도 pwInfoType.setWidth (tv_InformationType.getWidth())을 시도 할 수있다; –