diff --git a/C5/app/src/main/AndroidManifest.xml b/C5/app/src/main/AndroidManifest.xml index 57bb60a..1bc8186 100644 --- a/C5/app/src/main/AndroidManifest.xml +++ b/C5/app/src/main/AndroidManifest.xml @@ -39,7 +39,6 @@ android:allowBackup="true" android:icon="@drawable/ic_launcher" android:label="@string/app_name" - android:theme="@style/AppTheme" tools:replace="android:name"> aryContent = null; //标题,标题选举信息,提示信息,结果,页码 - private TextView tvTitle,tvTitleInfo,tvTipInfo,tvResult,tvPage; + private TextView tvTitle,tvTitleInfo,tvTipInfo,tvResult; private ListView listview; private Button btnConfirm; private Button btnModify; - private Button btnPageUp; - private Button btnPageDown; - private Button btnPageLast; + private View btnPageUp; + private View btnPageDown; + private View btnPageLast; private Button btnConfirmOK; private Button btnConfirmCancel; //分页 @@ -85,7 +86,6 @@ public class ElectionCustomFragment extends BaseFragment { mAdapter = new MyAdapter(getActivity()); listview.setAdapter(mAdapter); //显示页 - tvPage.setText(page + "/" + totalPage); if(voteInfo!=null){ tvTitle.setText(bill.title); showVote(); @@ -135,7 +135,6 @@ public class ElectionCustomFragment extends BaseFragment { public void onClick(View v) { page=totalPage; listview.setSelection(aryContent.size()); - tvPage.setText(page + "/" + totalPage); } }); @@ -198,10 +197,9 @@ public class ElectionCustomFragment extends BaseFragment { tvResult =(TextView) view.findViewById(R.id.singlevote_tv_result); confirm_panel = (RelativeLayout) view.findViewById(R.id.singlevote_confirm_panel); - tvPage = (TextView) view.findViewById(R.id.election_page); - btnPageUp = (Button) view.findViewById(R.id.election_pageup); - btnPageDown = (Button) view.findViewById(R.id.election_pagedown); - btnPageLast = (Button) view.findViewById(R.id.election_pagelast); + btnPageUp = view.findViewById(R.id.election_pageup); + btnPageDown = view.findViewById(R.id.election_pagedown); + btnPageLast = view.findViewById(R.id.election_pagelast); btnConfirm = (Button) view.findViewById(R.id.election_btn_confirm); btnModify = (Button)view.findViewById(R.id.election_btn_modify); @@ -370,6 +368,7 @@ public class ElectionCustomFragment extends BaseFragment { } else { holder = (ViewHolder) convertView.getTag(); } + convertView.setBackgroundColor(position % 2 == 0 ? Color.WHITE : Color.parseColor("#E5E5E5")); holder.tvNum.setText(String.valueOf(it.No)); holder.tvName.setText(String.valueOf(it.title)); if (it.result == 4) { diff --git a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionFragment.java b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionFragment.java index be8770d..8190308 100644 --- a/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionFragment.java +++ b/C5/app/src/main/java/com/sunvote/xpadapp/fragments/ElectionFragment.java @@ -6,7 +6,10 @@ import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.os.Bundle; import android.os.Environment; +import android.text.Spannable; +import android.text.SpannableStringBuilder; import android.text.TextUtils; +import android.text.style.AbsoluteSizeSpan; import android.util.Log; import android.view.KeyEvent; import android.view.LayoutInflater; @@ -45,6 +48,8 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; +import static com.sunvote.xpadapp.utils.MyStringUtil.replaceBlank; + public class ElectionFragment extends BaseFragment { private String TAG = "ElectionFragment"; private ArrayList aryContent = null; @@ -85,6 +90,7 @@ public class ElectionFragment extends BaseFragment { private String[] options; private ImageButton btn_all_ok,btn_all_xx; private TextView tv_all_ok,tv_all_xx; + private View list_election_item_add_btn; private boolean isAllO = false; private boolean isAllX = false; private StringBuilder voteNameStr = new StringBuilder(""); @@ -126,8 +132,8 @@ public class ElectionFragment extends BaseFragment { listview.setAdapter(mAdapter); tvTitle = (TextView) view.findViewById(R.id.election_title); - int houxuan = aryContent.size()-1; drawView = (PaletteView) view.findViewById(R.id.draw_view); + list_election_item_add_btn = view.findViewById(R.id.list_election_item_add_btn); imgClear = (ImageView) view.findViewById(R.id.clear_img); tvInfo = (TextView) view.findViewById(R.id.election_info); bottomLayout = (RelativeLayout) view.findViewById(R.id.election_pannal_bottom); @@ -140,6 +146,17 @@ public class ElectionFragment extends BaseFragment { btn_all_ok =(ImageButton) view.findViewById(R.id.btn_all_ok); btn_all_xx=(ImageButton) view.findViewById(R.id.btn_all_xx); View btnPageLast = view.findViewById(R.id.election_pagelast); + list_election_item_add_btn.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View v) { + if(votedCount>= voteInfo.select ){ + Toast.makeText(getActivity(), getString(R.string.max_select)+voteInfo.select+getString(R.string.person), Toast.LENGTH_SHORT).show(); + return; + } + drawView.clear(); + addOtherLayout.setVisibility(View.VISIBLE); + } + }); addOtherLayout.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -322,13 +339,12 @@ public class ElectionFragment extends BaseFragment { voteNameStr.append(strName).append(","); SharedPreferencesUtil.saveData(getActivity(),strName,getNotePath()); drawView.saveScreenShot(getNotePath()); - Log.d(TAG, "add other" + edtOther.getText().toString()); MultiTitleItem it = new MultiTitleItem(); it.startVote = true; it.No = --otherCount; it.result = 1; it.title = edtOther.getText().toString(); - aryContent.add(aryContent.size() - 1, it); + aryContent.add(aryContent.size() , it); mAdapter.notifyDataSetChanged(); addOtherLayout.setVisibility(View.GONE); checkVoted(); @@ -364,7 +380,11 @@ public class ElectionFragment extends BaseFragment { //tvInfo.setText(""); if(voteInfo!=null){ if(voteInfo!=null){ - tvTitle.setText(bill.title); + SpannableStringBuilder text1= new SpannableStringBuilder(replaceBlank(bill.title)); + text1.setSpan(new AbsoluteSizeSpan(70), 0, text1.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + SpannableStringBuilder text= new SpannableStringBuilder( "(侯选" + aryContent.size() + "人)"); + text.setSpan(new AbsoluteSizeSpan(45), 0, text.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); + tvTitle.setText(text1.append(text)); } showVote(); checkVoted(); @@ -628,43 +648,7 @@ public class ElectionFragment extends BaseFragment { Log.v("BaseAdapterTest", "getView " + position + " " + convertView); MultiTitleItem it = aryContent.get(position); - if (position > 0 && position == aryContent.size() - 1) { - convertView = mInflater.inflate(R.layout.list_election_item_add, null); - Button btnAdd = (Button) convertView.findViewById(R.id.list_election_item_add_btn); - int opposeCount=checkOpposeVoted(); - if (it.startVote && voteInfo.other > 0) { - //btnAdd.setEnabled(true); - if(((aryContent.size()-1)- voteInfo.select)= voteInfo.select ){ - Toast.makeText(getActivity(), getString(R.string.max_select)+voteInfo.select+getString(R.string.person), Toast.LENGTH_SHORT).show(); - return; - } - drawView.clear(); - addOtherLayout.setVisibility(View.VISIBLE); -// edtOther.requestFocus(); -// showInputMethod(edtOther, true, 1500); - - } - }); - return convertView; - } - - if (convertView == null || convertView.findViewById(R.id.list_election_item_add_btn) != null) { + if (convertView == null ) { convertView = mInflater.inflate(R.layout.list_election_item, null); holder = new ViewHolder(); holder.tvName = (TextView) convertView.findViewById(R.id.list_election_item_name); @@ -674,9 +658,9 @@ public class ElectionFragment extends BaseFragment { holder.RG = (RadioGroup) convertView.findViewById(R.id.list_election_item_radio_group); holder.btnDel = (RadioButton) convertView.findViewById(R.id.list_election_item_del); holder.imgBook = (PhotoView) convertView.findViewById(R.id.img_book); - convertView.setTag(holder); // ��ViewHolder���� + convertView.setTag(holder); } else { - holder = (ViewHolder) convertView.getTag(); // �� + holder = (ViewHolder) convertView.getTag(); } holder.seq.setText("" + (position+1)); holder.tvName.setText(String.valueOf(it.title)); @@ -720,7 +704,6 @@ public class ElectionFragment extends BaseFragment { btn_all_ok.setEnabled(true); } - /* ΪButton��ӵ���¼� */ holder.btnO.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { @@ -838,6 +821,12 @@ public class ElectionFragment extends BaseFragment { } mAdapter.notifyDataSetChanged(); listview.invalidate(); + + if((aryContent.size()- voteInfo.select) - - - - - + android:layout_toRightOf="@id/tv_num"/>--> - - +--> @@ -104,7 +98,7 @@ android:gravity="center" android:layout_centerVertical="true" android:text="反对" - android:textColor="@color/black" + android:textColor="@color/red" android:layout_toRightOf="@id/tv_agree" android:layout_marginLeft="40dp" android:textSize="@dimen/big_text_p5" /> @@ -116,7 +110,7 @@ android:gravity="center" android:layout_centerVertical="true" android:text="弃权" - android:textColor="@color/black" + android:textColor="@color/red" android:layout_toRightOf="@id/tv_oppose" android:layout_marginLeft="40dp" android:textSize="@dimen/big_text_p5" /> @@ -130,16 +124,14 @@ android:layout_alignParentBottom="true" android:layout_alignParentStart="true" android:alpha="0.9" - android:background="@drawable/gray_alpha" + android:background="@color/white" android:visibility="visible">