我有一个Main活动,其中有一些标签,每个标签显示一个片段,其中一个是相机片段,其中从相机捕获图像后,会出现一个弹出窗口,其中有一个名为lure的autocompletetextview和一个提交按钮。
设置autocompletetextview(lure)适配器,并在对话框弹出窗口中打印其大小,与预期的相同,如15。
问题是当我点击弹出对话框的提交按钮时,它的大小自动变为0,我想要实际大小,即15。
这是我的代码:
public class Camera_fragment extends Fragment {
private AutoCompleteTextView lure;
private ArrayList<String> lureArrayList
private ArrayAdapter<String> adapterLure;
Dialog layout;
View view;
public View onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, Bundle savedInstanceState) {
view= inflater.inflate(
R.layout.camera, container, false);
return view;
}
@Override
public void onActivityCreated(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onActivityCreated(savedInstanceState);
global=(GlobalData)getActivity().getApplicationContext();
layout = new Dialog(getActivity());
getrefrence();
arrayListDataFetchDB();
newImage.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View arg0)
{
Intent in= new Intent(getActivity(),com.camera.CameraCall.class);
startActivityForResult(in, CAPTURE_IMAGE);
}
});
newImage.performClick();
}
private void getrefrence()
{
newImage=(Button)view.findViewById(R.id.newCapture);
}
private void arrayListDataFetchDB()
{
lureArrayList=database.select("Select Lure_USED From LURE Group By Lure_USED Order By COUNT(Lure_USED) DESC");
}
private void adapterset()
{
adapterLure = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_dropdown_item_1line, lureArrayList);
lure.setAdapter(adapterLure);
}
private void initiatePopupWindow()
{
//layout.requestWindowFeature(layout.getWindow().FEATURE_NO_TITLE);
layout.setContentView(R.layout.after_catch_fish_popup_form);
Display display = getActivity().getWindowManager().getDefaultDisplay();
int mwidth = display.getWidth();
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
lp.copyFrom(layout.getWindow().getAttributes());
lp.width = mwidth;
layout.getWindow().setAttributes(lp);
layout.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
layout.show();
lure=(AutoCompleteTextView)layout.findViewById(R.id.lure);
Button submit=(Button)layout.findViewById(R.id.done);
adapterset();
lure.setThreshold(1);
Log.v("adapterSize",""+adapterLure.getCount());
submit.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Log.v("adapterSize1",""+adapterLure.getCount());
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data)
{
initiatePopupWindow();
}
}