diff --git a/app/src/main/java/com/qhclh/ytzh/work/productiondailyw/DetailsofdocumentsFragment.java b/app/src/main/java/com/qhclh/ytzh/work/productiondailyw/DetailsofdocumentsFragment.java index c2b5cac..660c665 100644 --- a/app/src/main/java/com/qhclh/ytzh/work/productiondailyw/DetailsofdocumentsFragment.java +++ b/app/src/main/java/com/qhclh/ytzh/work/productiondailyw/DetailsofdocumentsFragment.java @@ -1,13 +1,19 @@ package com.qhclh.ytzh.work.productiondailyw; +import android.content.DialogInterface; +import android.support.v7.app.AlertDialog; import android.view.View; import android.widget.AdapterView; import android.widget.ArrayAdapter; import android.widget.Spinner; +import android.widget.TextView; import com.qhclh.ytzh.R; import com.qhclh.ytzh.base.BaseFragment; +import java.util.ArrayList; +import java.util.List; + import butterknife.BindView; /** @@ -17,7 +23,7 @@ import butterknife.BindView; public class DetailsofdocumentsFragment extends BaseFragment { private ProductiondailywActivity act; @BindView(R.id.detaild_buildinghome) - Spinner detaild_buildinghome; + TextView detaild_buildinghome; @Override protected int setLayout() { return R.layout.fragment_detailsofdoc; @@ -32,23 +38,35 @@ public class DetailsofdocumentsFragment extends BaseFragment { protected void initData() { act = (ProductiondailywActivity) getActivity(); - ArrayAdapter adapter=new ArrayAdapter(getActivity(), android.R.layout.simple_spinner_item,BasicattributesFragment.houseNameList); - adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - detaild_buildinghome.setAdapter(adapter); } @Override protected void initOper() { - detaild_buildinghome.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { + detaild_buildinghome.setOnClickListener(new View.OnClickListener() { @Override - public void onItemSelected(AdapterView adapterView, View view, int i, long l) { - act.setHouseid(Long.parseLong(BasicattributesFragment.houseIdList.get(i))); - } - - @Override - public void onNothingSelected(AdapterView adapterView) { - + public void onClick(View view) { + int size = BasicattributesFragment.houseNameList.size(); + final String items[] = BasicattributesFragment.houseNameList.toArray(new String[size]); + new AlertDialog.Builder(getActivity()) + .setTitle("请选择栋舍") + .setIcon(R.mipmap.ic_launcher) + .setSingleChoiceItems(items, 0, + new DialogInterface.OnClickListener() { + public void onClick(DialogInterface dialog, int which) { + detaild_buildinghome.setText(items[which]); + act.setHouseid(Long.parseLong(BasicattributesFragment.houseIdList.get(which))); + dialog.dismiss(); + } + } + ) + .setNegativeButton("取消", new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialogInterface, int i) { + dialogInterface.dismiss(); + } + }) + .show(); } }); diff --git a/app/src/main/res/layout/fragment_detailsofdoc.xml b/app/src/main/res/layout/fragment_detailsofdoc.xml index 706aa89..72920fa 100644 --- a/app/src/main/res/layout/fragment_detailsofdoc.xml +++ b/app/src/main/res/layout/fragment_detailsofdoc.xml @@ -31,13 +31,14 @@ android:textColor="@color/grey888888" android:textSize="@dimen/text_size_18" /> -