Ejemplo n.º 1
0
 private void setItemViewTitleIndex(int itemViewTotal) {
   for (int index = 0; index < itemViewTotal; index++) {
     View itemView = mDynamicContainer.getChildAt(index);
     TextView textTitleIndex = (TextView) itemView.findViewById(R.id.dynamic_addView_title_index);
     textTitleIndex.setText(mActivity.getString(R.string.table_item_index, (index + 1)));
   }
 }
Ejemplo n.º 2
0
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);
          switch (msg.what) {
            case Constant.HANDLER_CALC_TIEM_INTERVAL:
              mTextTimeLen.setText(mTimeIntervalHours + mActivity.getString(R.string.hours));
              mTextTimeLen.setVisibility(View.VISIBLE);
              mLayoutCalcTimeWait.setVisibility(View.GONE);
              break;

            case Constant.HANDLER_DYNAMIC_DELETE_ITEM_VIEW:
              deleteItemView((View) msg.obj);
              break;

            default:
              break;
          }
        }
Ejemplo n.º 3
0
  private void addItemView() {
    /*
     * 在addItemView()方法中调用日志输出方法:Log.i(String, String,
     * Throwable),可以在让程序在日志控制台中以栈的形式列出程序是怎么执行到该方法
     */
    Log.i(TAG, "How Go To Here", new Exception("Stack Way"));

    View itemView = mInflater.inflate(R.layout.dynamic_add_view_v_item, null);
    itemView.setId(mItemViewIndex);

    TextView textTitleIndex = (TextView) itemView.findViewById(R.id.dynamic_addView_title_index);
    textTitleIndex.setText(mActivity.getString(R.string.table_item_index, (mItemViewIndex + 1)));

    TextView btnDeleteView = (TextView) itemView.findViewById(R.id.dynamic_addView_delete_view);
    btnDeleteView.setTag(itemView);
    btnDeleteView.setOnClickListener(mClickListener);
    if (mItemViewIndex == 0) { // 第一个条目不显示删除按钮
      btnDeleteView.setVisibility(View.GONE);
    }

    LinearLayout beginTimeLayout = (LinearLayout) itemView.findViewById(R.id.begin_time_layout);
    beginTimeLayout.setOnClickListener(mClickListener);
    LinearLayout endTimeLayout = (LinearLayout) itemView.findViewById(R.id.end_time_layout);
    endTimeLayout.setOnClickListener(mClickListener);
    // 开始时间和结束时间相互设置Tag用于当初始化其中任何一个时,另一个跟着变化
    beginTimeLayout.setTag(endTimeLayout);
    endTimeLayout.setTag(beginTimeLayout);

    mDynamicContainer.addView(
        itemView,
        mItemViewIndex++,
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    // 第一次添加ItemView后,若马上在此处获取ItemView的高度,则mItemViewHeight为零
    // mItemViewHeight = mDynamicContainer.getMeasuredHeight();
    // Log.i(TAG, "mItemViewHeight = " + mItemViewHeight);
  }