Example #1
0
 public void onClick(View v) {
   LinearLayout menu = (LinearLayout) v;
   switch (menu.getId()) {
     case R.id.menu1:
       Intent intent1 = new Intent(Goods_Rank_Show.this, Index.class);
       intent1.putExtra("tltle", "首页");
       startActivity(intent1);
       break;
     case R.id.menu2:
       Intent intent2 = new Intent(Goods_Rank_Show.this, Type.class);
       intent2.putExtra("tltle", "分类");
       startActivity(intent2);
       break;
     case R.id.menu3:
       Intent intent3 = new Intent(Goods_Rank_Show.this, StoresType.class);
       intent3.putExtra("tltle", "商家列表〃");
       startActivity(intent3);
       break;
     case R.id.menu4:
       Intent intent4 = new Intent(Goods_Rank_Show.this, Maps.class);
       intent4.putExtra("tltle", "百乐淘");
       startActivity(intent4);
       break;
     case R.id.menu5:
       Intent intent5 = new Intent(Goods_Rank_Show.this, More.class);
       intent5.putExtra("tltle", "更多");
       startActivity(intent5);
       break;
     default:
       break;
   }
 }
Example #2
0
  /**
   * Add buttons to the Dialog which has button area.
   *
   * @param context
   * @param buttonType The type of button that want to adds to Dialog. TCLAlertDialog.ONE_BUTTON :
   *     adds only one button. TCLAlertDialog.TWO_BUTTON : adds two button. Other : adds custom
   *     button.
   */
  public View setButton(Context context, int buttonType) {
    LayoutInflater inflate =
        (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    LinearLayout.LayoutParams lp =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);

    switch (buttonType) {
      case ONE_BUTTON:
        // mButtonView =
        // inflate.inflate(com.android.internal.R.layout.tcl_alert_button_one_especial, null);
        break;
      case TWO_BUTTON:
        mButtonView =
            inflate.inflate(com.android.internal.R.layout.tcl_alert_button_two_especial, null);
        break;
      case THREE_BUTTON:
        mButtonView =
            inflate.inflate(com.android.internal.R.layout.tcl_alert_button_three_especial, null);
        break;
      default:
        mButtonView = inflate.inflate(buttonType, null);
        break;
    }
    LinearLayout layout = getLayout(mButtonLayout.getId());

    lp.width = 700; // add by gaodw.
    // lp.height = 150; //add by gaodw.

    layout.addView(mButtonView, lp);
    return mButtonView;
  }
Example #3
0
  // the pin
  private ImageView getImagePin() {
    ivPin = new ImageView(getContext());
    int resId = getBitmapRes(activity, "pin");
    if (resId > 0) {
      ivPin.setImageResource(resId);
    }
    int dp_80 = dipToPx(getContext(), 80);
    int dp_36 = dipToPx(getContext(), 36);
    RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams(dp_80, dp_36);
    lp.topMargin = dipToPx(getContext(), 6);
    lp.addRule(RelativeLayout.ALIGN_TOP, llBody.getId());
    lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    ivPin.setLayoutParams(lp);
    ivPin.setVisibility(View.GONE);

    return ivPin;
  }
Example #4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    LinearLayout la = new LinearLayout(this);
    setContentView(la);

    TextView tv = new TextView(this);
    tv.setText("main");
    la.addView(tv);

    LinearLayout laFrag = new LinearLayout(this);
    laFrag.setId(62546523);
    la.addView(laFrag);

    FragmentTransaction trFragments = getFragmentManager().beginTransaction();
    Main10Frag1 frag = new Main10Frag1();

    trFragments.add(laFrag.getId(), frag);
    trFragments.commit();
  }
  private void calculateFramesArea(View layoutRoot) {
    if (layoutRoot instanceof TextView && !(layoutRoot instanceof EditText)) {
      if (((TextView) layoutRoot).getLineCount() > 1) {
        this.badPhenotype = true;
      }

      return;
    }
    if (layoutRoot instanceof LinearLayout) {
      LinearLayout root = (LinearLayout) layoutRoot;
      if (root.getId() == R.id.templateFrame) {
        this.framesArea += layoutRoot.getHeight() * layoutRoot.getWidth();
      }

      for (int i = 0; i < root.getChildCount() && this.badPhenotype == false; i++) {
        calculateFramesArea(root.getChildAt(i));
      }
    }

    return;
  }
 @Override
 public void onClick(View v) {
   // TODO Auto-generated method stub
   if (v.getId() == ll_Other.getId()) {
     // bdl.putInt("index", 5);
   } else {
     Intent intent = new Intent(getActivity(), Help_sub_Activity.class);
     Bundle bdl = new Bundle();
     if (v.getId() == ll_recharge.getId()) {
       bdl.putInt("index", 0);
     } else if (v.getId() == ll_addmoney.getId()) {
       bdl.putInt("index", 1);
     } else if (v.getId() == ll_offer.getId()) {
       bdl.putInt("index", 2);
     } else if (v.getId() == ll_tansfer.getId()) {
       bdl.putInt("index", 3);
     } else if (v.getId() == ll_account.getId()) {
       bdl.putInt("index", 4);
     }
     intent.putExtras(bdl);
     startActivity(intent);
   }
 }
  @Override
  public void onClick(View v) {
    if (v.getId() == tv_fullname.getId() || v.getId() == tv_username.getId()) {
      // GOTO PROFILE WHEN NAME OR USERNAME IS CLICKED
      Intent i = new Intent(context, ProfileActivity.class);
      i.putExtra("UserId", userId);
      context.startActivity(i);
    } else if (v.getId() == R.id.pt_commentBtn) {
      Intent i = new Intent(context, CommentActivity.class);
      i.putExtra("PostId", postId);
      i.putExtra("FullName", tv_fullname.getText().toString());
      i.putExtra("isOwned", owned);
      context.startActivity(i);
      ((Activity) context).overridePendingTransition(R.animator.animate3, R.animator.animate2);
    } else if (v.getId() == R.id.pt_shareBtn) {
      Intent i = new Intent(context, ShareActivity.class);
      if (share_postId.equals("")) i.putExtra("PostId", postId);
      else i.putExtra("PostId", share_postId);
      i.putExtra("OwnerId", schoolId);
      context.startActivity(i);
      ((Activity) context).overridePendingTransition(R.animator.animate3, R.animator.animate2);
    } else if (v.getId() == upvote.getId()) {
      upvote.setVisibility(View.INVISIBLE);
      upvote2.setVisibility(View.VISIBLE);
      Intent intent = new Intent(context, UpvoteService.class);
      intent.putExtra("userId", schoolId);
      intent.putExtra("postId", postId);
      context.startService(intent);
    } else if (v.getId() == upvote2.getId()) {
      upvote2.setVisibility(View.INVISIBLE);
      upvote.setVisibility(View.VISIBLE);

      Intent intent = new Intent(context, UpvoteService.class);
      intent.putExtra("userId", schoolId);
      intent.putExtra("postId", postId);
      context.startService(intent);
    } else if (v.getId() == options.getId()) {
      // Creating the instance of PopupMenu
      PopupMenu popup = new PopupMenu(context, options);
      // Inflating the Popup using xml file
      if (owned) {
        popup.getMenuInflater().inflate(R.menu.menu_options, popup.getMenu());
      } else {
        popup.getMenuInflater().inflate(R.menu.menu_options2, popup.getMenu());
      }

      // registering popup with OnMenuItemClickListener
      popup.setOnMenuItemClickListener(
          new PopupMenu.OnMenuItemClickListener() {
            public boolean onMenuItemClick(MenuItem item) {
              if (item.getTitle().equals("Report")) {
                Intent i = new Intent(context, ReportActivity.class);
                i.putExtra("PostId", postId);
                i.putExtra("ReporterId", schoolId);
                i.putExtra("ReferenceTable", "post");
                context.startActivity(i);
              } else if (item.getTitle().equals("Edit")) {
                Intent i = new Intent(context, EditPostActivity.class);
                i.putExtra("PostId", postId);
                context.startActivity(i);
              } else {
                Intent i = new Intent(context, DeleteService.class);
                i.putExtra("PostId", postId);
                i.putExtra("Action", "post");
                context.startService(i);
              }
              return true;
            }
          });

      popup.show(); // showing popup menu
    } else if (v.getId() == fileCV.getId()) {
      Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(fileUrl));
      context.startActivity(browserIntent);

    } else if (v.getId() == share_file_name.getId()) {
      Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(shareFileUrl));
      context.startActivity(browserIntent);
    } else {
      // GOTO VIEW POST
      Intent i = new Intent(context, PostViewActivity.class);
      i.putExtra("PostId", postId);
      context.startActivity(i);
    }
  }
Example #8
0
  public View getAdapterView(
      final Context context, final AdInfo adInfo, int itemWidth, int itemHeight) {
    // 对小屏手机进行屏幕判断
    int displaySize = SDKUtils.getDisplaySize(context);

    // 整体布局
    RelativeLayout whole_layout = null;

    GradientDrawable click_bg_grad =
        new GradientDrawable(
            Orientation.TOP_BOTTOM,
            new int[] {
              Color.parseColor("#FFD700"), Color.parseColor("#FFB90F"), Color.parseColor("#FFD700")
            });

    // 广告数据布局
    RelativeLayout r_layout = null;
    try {
      whole_layout = new RelativeLayout(context);
      if (itemWidth == 0 || itemHeight == 0) {
        itemWidth = ((Activity) context).getWindowManager().getDefaultDisplay().getWidth();
        // item的默认高度
        if (displaySize == 320) {
          itemHeight = 55;
        } else if (displaySize == 240) {
          itemHeight = 40;
        } else if (displaySize == 720) {
          itemHeight = 120;
        } else if (displaySize == 1080) {
          itemHeight = 180;
        } else {
          itemHeight = 100;
        }
      }
      whole_layout.setLayoutParams(new ListView.LayoutParams(itemWidth, itemHeight));

      r_layout = new RelativeLayout(context);

      int item_whole_bg_id =
          context.getResources().getIdentifier("item_bg", "drawable", context.getPackageName());

      if (item_whole_bg_id != 0) {
        r_layout.setLayoutParams(
            new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
        r_layout.setBackgroundResource(item_whole_bg_id);
      }
      //			r_layout.setPadding(0, 0, 0, 0);

      // 图标
      ImageView app_icon = new ImageView(context);
      app_icon.setId(1);
      app_icon.setScaleType(ImageView.ScaleType.FIT_CENTER);

      app_icon.setImageDrawable(new BitmapDrawable(adInfo.getAdIcon()));
      app_icon.setPadding(5, 5, 5, 5);

      RelativeLayout.LayoutParams icon_img_params = null;
      if (displaySize == 320) {
        app_icon.setPadding(4, 4, 4, 4);
        icon_img_params = new RelativeLayout.LayoutParams(50, 50);
      } else if (displaySize == 240) {
        app_icon.setPadding(2, 2, 2, 2);
        icon_img_params = new RelativeLayout.LayoutParams(36, 36);
      } else if (displaySize == 720) {
        app_icon.setPadding(8, 8, 8, 8);
        icon_img_params = new RelativeLayout.LayoutParams(100, 100);
      } else if (displaySize == 1080) {
        app_icon.setPadding(10, 10, 10, 10);
        icon_img_params = new RelativeLayout.LayoutParams(140, 140);
      } else {
        app_icon.setPadding(5, 5, 5, 5);
        icon_img_params = new RelativeLayout.LayoutParams(75, 75);
      }
      icon_img_params.addRule(RelativeLayout.CENTER_VERTICAL);
      icon_img_params.leftMargin = 5;

      // 加载所有文字内容的整体布局
      LinearLayout layout = new LinearLayout(context);
      layout.setLayoutParams(
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      layout.setOrientation(LinearLayout.VERTICAL);

      int item_text_bg_id =
          context
              .getResources()
              .getIdentifier("item_text_bg", "drawable", context.getPackageName());
      if (item_text_bg_id != 0) {
        //				layout.setBackgroundResource(item_text_bg_id);
      }
      layout.setId(2);

      // 加载广告名称和广告大小的布局
      RelativeLayout title_size_layout = new RelativeLayout(context);

      // 广告名称
      TextView app_name = new TextView(context);
      app_name.setId(2);
      app_name.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

      app_name.setText(adInfo.getAdName());
      app_name.setTextSize(18);
      app_name.setTextColor(Color.BLACK);
      app_name.setPadding(10, 0, 0, 0);

      // 广告大小
      TextView app_size = new TextView(context);
      app_size.setText(adInfo.getFilesize() + "M");
      app_size.setTextSize(12);
      app_size.setTextColor(Color.GRAY);
      app_size.setPadding(5, 0, 5, 0);

      RelativeLayout.LayoutParams params4 =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      params4.addRule(RelativeLayout.ALIGN_TOP, app_name.getId());
      params4.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

      title_size_layout.addView(app_name);
      title_size_layout.addView(app_size, params4);

      // 广告语
      TextView content = new TextView(context);
      content.setLayoutParams(
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
      content.setText(adInfo.getAdText());
      content.setPadding(10, 0, 0, 0);
      content.setTextColor(Color.GRAY);

      layout.addView(title_size_layout);
      layout.addView(content);

      // 下载按钮
      LinearLayout down_layout = new LinearLayout(context);
      down_layout.setOrientation(LinearLayout.HORIZONTAL);
      down_layout.setGravity(Gravity.CENTER);
      down_layout.setId(3);

      // 直接加载下载图标的布局
      RelativeLayout down_img_layout = new RelativeLayout(context);
      int down_layout_width = 75;
      if (displaySize == 320) {
        down_layout_width = 45;
      } else if (displaySize == 240) {
        down_layout_width = 30;
      } else if (displaySize == 720) {
        down_layout_width = 100;
      } else if (displaySize == 1080) {
        down_layout_width = 150;
      }
      down_img_layout.setLayoutParams(
          new LinearLayout.LayoutParams(down_layout_width, LayoutParams.FILL_PARENT));

      ImageView downImage = new ImageView(context);
      int down_bg_id =
          context.getResources().getIdentifier("down_ico", "drawable", context.getPackageName());

      if (down_bg_id != 0) {
        downImage.setImageResource(down_bg_id);
      }

      // 下载按钮的点击半透明遮罩效果布局
      final LinearLayout d_layout = new LinearLayout(context);
      d_layout.setLayoutParams(
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      //			d_layout.setBackgroundColor(Color.argb(80, 0, 0, 0));
      //			d_layout.setBackgroundColor(Color.parseColor("#AAFFD700"));
      d_layout.setBackgroundDrawable(click_bg_grad);
      d_layout.setVisibility(View.INVISIBLE);

      RelativeLayout.LayoutParams down_img_params =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      down_img_params.addRule(RelativeLayout.CENTER_IN_PARENT);

      down_img_layout.addView(d_layout);
      down_img_layout.addView(downImage, down_img_params);

      // 竖直分隔线
      int line_size = 4;
      if (displaySize == 240) {
        line_size = 2;
      }
      LinearLayout line_layout_2 = new LinearLayout(context);
      line_layout_2.setLayoutParams(
          new LinearLayout.LayoutParams(line_size, LayoutParams.FILL_PARENT));

      // 颜色渐变
      GradientDrawable grad =
          new GradientDrawable(
              Orientation.LEFT_RIGHT,
              new int[] {
                Color.parseColor("#cccccc"),
                Color.parseColor("#ffffff"),
                Color.parseColor("#cccccc")
              });
      line_layout_2.setBackgroundDrawable(grad);

      down_layout.addView(line_layout_2);
      down_layout.addView(down_img_layout);

      down_img_layout.setOnTouchListener(
          new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
                  // 点击时,ListView的item产生被点击效果(半透明遮罩)
                case MotionEvent.ACTION_DOWN:
                  d_layout.setVisibility(View.VISIBLE);
                  break;
                  // 离开点击区域,ListView的item点击效果消失
                case MotionEvent.ACTION_CANCEL:
                  d_layout.setVisibility(View.INVISIBLE);
                  break;
                  // 点击后抬起时,ListView的item点击效果消失
                case MotionEvent.ACTION_UP:
                  d_layout.setVisibility(View.INVISIBLE);
                  break;
              }
              return false;
            }
          });

      down_img_layout.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              AppConnect.getInstance(context).downloadAd(context, adInfo.getAdId());
            }
          });

      RelativeLayout.LayoutParams params2 =
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      params2.addRule(RelativeLayout.RIGHT_OF, app_icon.getId());
      params2.addRule(RelativeLayout.LEFT_OF, down_layout.getId());
      params2.addRule(RelativeLayout.CENTER_VERTICAL);

      RelativeLayout.LayoutParams params3 =
          new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
      //			params3.addRule(RelativeLayout.RIGHT_OF, layout.getId());
      params3.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);

      //			int width = ((Activity)context).getWindowManager().getDefaultDisplay().getWidth()-83;
      // 点击效果的半透明遮罩布局
      final LinearLayout l_layout = new LinearLayout(context);
      l_layout.setLayoutParams(
          new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT));
      //			l_layout.setBackgroundColor(Color.argb(80, 0, 0, 0));//黑色
      //			l_layout.setBackgroundColor(Color.argb(80, 30, 144, 255));//淡蓝色
      //			l_layout.setBackgroundColor(Color.parseColor("#AAFFD700"));
      l_layout.setBackgroundDrawable(click_bg_grad);
      l_layout.setVisibility(View.INVISIBLE);

      r_layout.addView(l_layout);
      r_layout.addView(app_icon, icon_img_params);
      r_layout.addView(down_layout, params3);
      r_layout.addView(layout, params2);

      whole_layout.addView(r_layout);

      r_layout.setOnTouchListener(
          new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
              switch (event.getAction()) {
                  // 点击时,ListView的item产生被点击效果(半透明遮罩)
                case MotionEvent.ACTION_DOWN:
                  l_layout.setVisibility(View.VISIBLE);
                  break;
                  // 离开点击区域,ListView的item点击效果消失
                case MotionEvent.ACTION_CANCEL:
                  l_layout.setVisibility(View.INVISIBLE);
                  break;
                  // 点击后抬起时,ListView的item点击效果消失
                case MotionEvent.ACTION_UP:
                  l_layout.setVisibility(View.INVISIBLE);
                  break;
              }
              return false;
            }
          });

      r_layout.setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View v) {
              AppDetail.getInstanct().showAdDetail(context, adInfo);
            }
          });

    } catch (Exception e) {
      e.printStackTrace();
    }
    return whole_layout;
  }