示例#1
0
  // platform logos
  private LinearLayout getPlatformList() {
    LinearLayout llToolBar = new LinearLayout(getContext());
    LayoutParams lpTb = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    llToolBar.setLayoutParams(lpTb);

    TextView tvShareTo = new TextView(getContext());
    int resId = getStringRes(activity, "ssdk_oks_share_to");
    if (resId > 0) {
      tvShareTo.setText(resId);
    }
    tvShareTo.setTextColor(0xffcfcfcf);
    tvShareTo.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 18);
    int dp_9 = dipToPx(getContext(), 9);
    LayoutParams lpShareTo = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpShareTo.gravity = Gravity.CENTER_VERTICAL;
    lpShareTo.setMargins(dp_9, 0, 0, 0);
    tvShareTo.setLayoutParams(lpShareTo);
    llToolBar.addView(tvShareTo);

    HorizontalScrollView sv = new HorizontalScrollView(getContext());
    sv.setHorizontalScrollBarEnabled(false);
    sv.setHorizontalFadingEdgeEnabled(false);
    LayoutParams lpSv = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpSv.setMargins(dp_9, dp_9, dp_9, dp_9);
    sv.setLayoutParams(lpSv);
    llToolBar.addView(sv);

    llPlat = new LinearLayout(getContext());
    llPlat.setLayoutParams(
        new HorizontalScrollView.LayoutParams(
            LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT));
    sv.addView(llPlat);

    return llToolBar;
  }
  public static void addActionsButton(BaseButton baseButton) {
    Drawable iconImage = mShell.getResources().getDrawable(baseButton.getButtonIconId());

    int ten_dip = (int) (10 * mShell.getResources().getDisplayMetrics().density);

    ImageView buttonIcon = new ImageView(mShell.getContext());
    buttonIcon.setImageDrawable(iconImage);
    LayoutParams iconParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    iconParams.setMargins(ten_dip, 0, 0, 0);
    iconParams.gravity = Gravity.CENTER_VERTICAL;

    TextView buttonText = new TextView(mShell.getContext());
    buttonText.setText(baseButton.getButtonText());
    buttonText.setTextColor(Color.WHITE);
    buttonText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    LayoutParams textParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    buttonText.setPadding(ten_dip, ten_dip, ten_dip, ten_dip);

    LinearLayout button = new LinearLayout(mShell.getContext());
    button.addView(buttonIcon, iconParams);
    button.addView(buttonText, textParams);

    baseButton.setActionImageView(buttonIcon);
    baseButton.setActionTextView(buttonText);

    button.setOnClickListener(baseButton.getOnClickListener());

    ActionButtonRunnable addButtonRunnable = new ActionButtonRunnable(button);
    mCurrentActivity.runOnUiThread(addButtonRunnable);
  }
示例#3
0
  private LinearLayout getMainBody() {
    LinearLayout llMainBody = new LinearLayout(getContext());
    llMainBody.setOrientation(LinearLayout.VERTICAL);
    LayoutParams lpMain = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpMain.weight = 1;
    int dp_4 = dipToPx(getContext(), 4);
    lpMain.setMargins(dp_4, dp_4, dp_4, dp_4);
    llMainBody.setLayoutParams(lpMain);

    LinearLayout llContent = new LinearLayout(getContext());
    LayoutParams lpContent = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    lpContent.weight = 1;
    llMainBody.addView(llContent, lpContent);

    // share content editor
    etContent = new EditText(getContext());
    etContent.setGravity(Gravity.LEFT | Gravity.TOP);
    etContent.setBackgroundDrawable(null);
    etContent.setText(String.valueOf(shareParamMap.get("text")));
    etContent.addTextChangedListener(this);
    LayoutParams lpEt = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpEt.weight = 1;
    etContent.setLayoutParams(lpEt);
    llContent.addView(etContent);

    llContent.addView(getThumbView());
    llMainBody.addView(getBodyBottom());

    return llMainBody;
  }
示例#4
0
  /** display platform list */
  @SuppressLint("NewApi")
  public void afterPlatformListGot() {
    int size = platformList == null ? 0 : platformList.length;
    views = new View[size];

    final int dp_24 = dipToPx(getContext(), 24);
    LayoutParams lpItem = new LayoutParams(dp_24, dp_24);
    final int dp_9 = dipToPx(getContext(), 9);
    lpItem.setMargins(0, 0, dp_9, 0);
    FrameLayout.LayoutParams lpMask =
        new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
    lpMask.gravity = Gravity.LEFT | Gravity.TOP;
    int selection = 0;
    for (int i = 0; i < size; i++) {
      FrameLayout fl = new FrameLayout(getContext());
      fl.setLayoutParams(lpItem);
      if (i >= size - 1) {
        fl.setLayoutParams(new LayoutParams(dp_24, dp_24));
      }
      llPlat.addView(fl);
      fl.setOnClickListener(this);

      ImageView iv = new ImageView(getContext());
      iv.setScaleType(ScaleType.CENTER_INSIDE);
      iv.setImageBitmap(getPlatLogo(platformList[i]));
      iv.setLayoutParams(
          new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
      fl.addView(iv);

      views[i] = new View(getContext());
      views[i].setBackgroundColor(0xcfffffff);
      views[i].setOnClickListener(this);
      String platformName = platformList[i].getName();
      for (Platform plat : platforms) {
        if (platformName.equals(plat.getName())) {
          views[i].setVisibility(View.INVISIBLE);
          selection = i;
        }
      }
      views[i].setLayoutParams(lpMask);
      fl.addView(views[i]);
    }

    final int postSel = selection;
    UIHandler.sendEmptyMessageDelayed(
        0,
        333,
        new Callback() {
          @SuppressLint("NewApi")
          public boolean handleMessage(Message msg) {
            HorizontalScrollView hsv = (HorizontalScrollView) llPlat.getParent();
            hsv.scrollTo(postSel * (dp_24 + dp_9), 0);
            return false;
          }
        });
  }
示例#5
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_diary);

    Bundle bundle = getIntent().getExtras();
    TimeLineModel tlm = (TimeLineModel) bundle.getSerializable(ARG_KEY);

    String title = tlm.getTitle();
    String content = tlm.getContent();
    String date = tlm.getDate();
    String audio = tlm.getAudio();

    TextView titleView = (TextView) findViewById(R.id.diary_title);
    TextView contentView = (TextView) findViewById(R.id.diary_content);
    TextView dateView = (TextView) findViewById(R.id.diary_date);
    LinearLayout audioButtons = (LinearLayout) findViewById(R.id.diary_audio);

    titleView.setText(title);
    contentView.setText(content);
    dateView.setText(date);

    LayoutParams lparams = new LayoutParams(200, 110);
    lparams.setMargins(10, 10, 10, 10);

    String[] audios = new String[] {};
    if (!audio.isEmpty()) audios = audio.split("\n");

    for (int i = 0; i < audios.length; i++) {
      String rawAudioInfo = audios[i];
      String[] audioInfo = rawAudioInfo.split(","); // array[0]: duration, array[1]: path
      // Button btn = new AudioPlayButton(this, audioInfo[0], audioInfo[1]);
      Button btn = new Button(this);
      btn.setLayoutParams(lparams);
      btn.setText(audioInfo[0]);
      btn.setTag(audioInfo[1]);
      btn.setBackgroundResource(R.color.mainRed);

      btn.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              play((String) v.getTag());
            }
          });
      audioButtons.addView(btn, lparams);
    }
  }
 @Override
 protected void applyTransformation(float interpolatedTime, Transformation t) {
   super.applyTransformation(interpolatedTime, t);
   if (interpolatedTime < 1.0f) {
     int newMarginBottom =
         mMarginBottomFromY + (int) ((mMarginBottomToY - mMarginBottomFromY) * interpolatedTime);
     mLayoutParams.setMargins(
         mLayoutParams.leftMargin,
         mLayoutParams.topMargin,
         mLayoutParams.rightMargin,
         newMarginBottom);
     mView.getParent().requestLayout();
     // Log.v("CZ","newMarginBottom..." + newMarginBottom +
     // " , mLayoutParams.topMargin..." + mLayoutParams.topMargin);
   } else if (mVanishAfter) {
     mView.setVisibility(View.GONE);
   }
 }
示例#7
0
  @SuppressLint("NewApi")
  private void setSpinner(Spinner spinner, List<String> data) {
    LayoutParams lpView = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lpView.setMargins(50, 10, 10, 10);
    spinner.setLayoutParams(lpView);
    // Drawable d = mContext.getResources().getDrawable(
    //		R.drawable.dropdown_selector);
    // spinner.setBackground(d); // API Level 16
    // spinner.setBackgroundResource(R.drawable.dropdown_selector);
    spinner.setOnItemSelectedListener(itemSelectedListener);
    // TestAdapter adapter = new TestAdapter(mContext, data);
    ArrayAdapter<String> nameAdapter =
        new ArrayAdapter<String>(mContext, android.R.layout.simple_spinner_item, data);

    nameAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    spinner.setAdapter(nameAdapter);
  }
示例#8
0
 @Override
 public View HockView(
     int position, View view, ViewGroup parent, int resID, Context context, GridViewData t) {
   // TODO Auto-generated method stub
   ViewHocker hocker = null;
   if (view == null) {
     view = LayoutInflater.from(context).inflate(resID, null);
     hocker = new ViewHocker();
     LayoutParams params = new LayoutParams(Constract.width / 2, Constract.width / 2);
     params.setMargins(2, 2, 2, 2);
     hocker.iv = (RoundedImageView) view.findViewById(R.id.item_grid_iv);
     hocker.iv.setLayoutParams(params);
     hocker.tv = (TextView) view.findViewById(R.id.item_grid_tv);
     view.setTag(hocker);
   } else {
     hocker = (ViewHocker) view.getTag();
   }
   imageLoader.displayImage(t.url, hocker.iv);
   hocker.tv.setText(t.url);
   return view;
 }
  private LinearLayout createLayout(Gene root, LinearLayout view) {
    LayoutCodon codon = (LayoutCodon) root.getCodon();
    SOLinearLayout layout = new SOLinearLayout(this.context);
    LayoutParams params = null;
    if (codon.getWeight() == 1) {
      params =
          new LayoutParams(
              LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    } else {
      params = new LayoutParams(0, LinearLayout.LayoutParams.WRAP_CONTENT, codon.getWeight());
    }
    if (codon.isFrame()) {
      LayoutInflater li = LayoutInflater.from(context);

      layout = (SOLinearLayout) li.inflate(R.layout.templateframe, null);
      layout.setLoopingInterval(1000);
      layout.setId(R.id.templateFrame);
      if (codon.isGetLayout()) {
        layout.setGetLayout(true);
      }
      TextView tv = (TextView) layout.findViewById(R.id.textFrame);
      tv.setText(codon.getText().toUpperCase());
      params.setMargins(10, 10, 0, 0);
    } else {
      if (codon.getOrientation() == 0) {
        layout.setOrientation(LinearLayout.HORIZONTAL);
      } else {
        layout.setOrientation(LinearLayout.VERTICAL);
      }
    }
    codon.setWidth(layout.getWidth());
    codon.setHeight(layout.getHeight());
    view.addView(layout, params);
    view = layout;

    return view;
  }
  public Button createButton(CharSequence text, View.OnClickListener click) {

    float density = this.getContext().getResources().getDisplayMetrics().density;
    int button_height = (int) (36.0f * density);
    int button_margin = (int) (4.0f * density);
    int button_padding = (int) (8.0f * density);
    int min_width = (int) (64.0f * density);

    LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, button_height);
    params.setMargins(button_margin, 0, 0, 0);

    Button button = new Button(this.getContext());
    button.setLayoutParams(params);
    button.setPadding(button_padding, 0, button_padding, 0);
    button.setBackgroundResource(R.drawable.touch_holo_light_round_angle);
    button.setTextColor(this.getContext().getResources().getColor(R.color.blue));
    button.setTextSize(16);
    button.setMinWidth(min_width);
    button.setOnClickListener(new OnClick(this, click));
    button.setText(text);
    button.setTypeface(null, Typeface.BOLD);

    return button;
  }
示例#11
0
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    int margin = Utils.dpToPx(0.02f * Utils.getDisplayMetrics().widthPixels);

    SpannableStringBuilder prettyMessage = new SpannableStringBuilder(message);
    int italicsFrom = message.indexOf(italicsString),
        italicsTo = italicsFrom + italicsString.length();
    prettyMessage.setSpan(
        new StyleSpan(Typeface.ITALIC), italicsFrom, italicsTo, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

    this.layout = new LinearLayout(this);
    this.layout.setOrientation(Orientation.VERTICAL);
    this.setContentView(this.layout);

    ScrollView sv = new ScrollView(this);
    LayoutParams scrollParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    scrollParams.weight = 1;
    // this.layout.addView(sv, scrollParams);

    LinearLayout innerLayout = new LinearLayout(this);
    innerLayout.setOrientation(Orientation.VERTICAL);
    LayoutParams ilParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    ilParams.weight = 1;
    sv.addView(innerLayout, ilParams);

    this.messageText = new TextView(this);
    messageText.setText(prettyMessage);
    messageText.setTextSize(14);
    messageText.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
    LayoutParams textParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    textParams.weight = 0;
    textParams.gravity = Gravity.LEFT | Gravity.CENTER_VERTICAL;
    textParams.setMargins(margin, margin, margin, margin / 2);
    this.layout.addView(messageText, textParams);

    final EditText sender = new EditText(this);
    sender.setInputType(InputType.TYPE_CLASS_TEXT);
    sender.setHint("Je e-mailadres (als je iets terug wilt horen)");
    LayoutParams senderParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    senderParams.weight = 0;
    senderParams.setMargins(margin, 0, margin, 0);
    this.layout.addView(sender, senderParams);

    final EditText detail = new EditText(this);
    detail.setHint("Wat wil je zeggen?");
    detail.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE);
    detail.setGravity(Gravity.TOP);
    LayoutParams detailParams = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
    detailParams.weight = 0.5f;
    detailParams.setMargins(margin, 0, margin, 0);
    this.layout.addView(detail, detailParams);

    loading = new ProgressBar(activity);
    loading.setIndeterminate(true);

    submit = new Button(this);
    submit.setText("Versturen");
    submitParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    submitParams.weight = 0;
    submitParams.setMargins(0, 0, 0, margin);
    submitParams.gravity = Gravity.CENTER;

    submit.setOnClickListener(
        new OnClickListener() {
          public void onClick(View v) {
            activity.hideOnScreenKeyboard(sender.getWindowToken());
            activity.hideOnScreenKeyboard(detail.getWindowToken());
            layout.removeView(submit);
            layout.addView(loading, submitParams);
            new FeedbackSender(sender.getText().toString(), detail.getText().toString()).execute();
          }
        });

    this.layout.addView(submit, submitParams);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    final OnClickListener onClickStartFunc =
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            Intent intent = new Intent(SetupChoicesActivity.this, Choose4uActivity.class);
            startActivity(intent);
          }
        };

    final OnClickListener onClickResetFunc =
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            new AlertDialog.Builder(SetupChoicesActivity.this)
                .setMessage(getString(R.string.reset_msg))
                .setIcon(android.R.drawable.ic_dialog_info)
                .setPositiveButton(
                    getString(R.string.ok),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int which) {
                        reset();
                      }
                    })
                .setNegativeButton(
                    getString(R.string.cancel),
                    new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int whichButton) {}
                    })
                .create()
                .show();
          }
        };

    Button btn_start = (Button) findViewById(R.id.btn_start_tb);
    Button btn_reset = (Button) findViewById(R.id.btn_reset_tb);

    findViewById(R.id.btn_title).setOnClickListener(onClickStartFunc);
    findViewById(R.id.btn_start).setOnClickListener(onClickStartFunc);
    btn_start.setOnClickListener(onClickStartFunc);
    btn_start.setTextColor(Color.WHITE);

    findViewById(R.id.btn_reset).setOnClickListener(onClickResetFunc);
    btn_reset.setOnClickListener(onClickResetFunc);
    btn_reset.setTextColor(Color.WHITE);

    DisplayMetrics displayMetrics = getResources().getDisplayMetrics();
    int width = displayMetrics.widthPixels;

    LinearLayout choices = (LinearLayout) findViewById(R.id.choices);

    LinearLayout[] lyt = new LinearLayout[2];
    for (int i = 0; i < 4; i++) {
      if (i < 2) {
        lyt[i] = new LinearLayout(this);
        lyt[i].setOrientation(LinearLayout.HORIZONTAL);
      } else {
        i = (i == 2 ? 3 : 2);
      }

      int margin = 4;
      final int current = i;
      img[i] = new ImageView(this);
      LayoutParams params = new LayoutParams(width / 2 - 2 * margin, width / 2 - 2 * margin);
      params.setMargins(margin, margin, margin, margin);
      img[i].setLayoutParams(params);
      img[i].setScaleType(ScaleType.FIT_CENTER);

      Bitmap bitmap = null;
      File file = new File(img_prefix + imgstr[i]);
      if (!file.exists()) {
        try {
          bitmap = BitmapFactory.decodeStream(getAssets().open(imgstr[i]));
        } catch (IOException e) {
          e.printStackTrace();
        }
      } else {
        bitmap = BitmapFactory.decodeFile(img_prefix + imgstr[i]);
      }
      if (bitmap != null) {
        img[i].setImageBitmap(bitmap);
      }

      img[i].setOnClickListener(
          new OnClickListener() {
            @Override
            public void onClick(View arg0) {
              String[] options = getResources().getStringArray(R.array.options_array);
              AlertDialog dialog =
                  new AlertDialog.Builder(SetupChoicesActivity.this)
                      // .setIcon(android.R.drawable.ic_dialog_info)
                      .setTitle(getString(R.string.option_setting))
                      .setItems(options, onselect)
                      .create();
              dialog.show();
            }

            DialogInterface.OnClickListener onselect =
                new DialogInterface.OnClickListener() {
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    pos = current;
                    switch (which) {
                      case 0:
                        onClickCamera();
                        break;
                      case 1:
                        onClickGallery();
                        break;
                      case 2:
                        onClickDefault();
                        break;
                    }
                  }
                };
          });

      img[i].setOnLongClickListener(
          new OnLongClickListener() {
            @Override
            public boolean onLongClick(View v) {
              return true;
            }
          });

      lyt[i / 2].addView(img[i]);
      if (i % 2 != 0) choices.addView(lyt[i / 2]);

      if (i == 2) break;
      if (i == 3) i = 2;
    }

    mHandler.post(mAdRefreshProc);
  }
示例#13
0
  private void createNewContactObject(String type, View my_contact_view) {
    if (my_contact_view == null) {
      my_contact_view = fragment_mycontact.getView();
    }

    if (my_contact_view == null) return;

    LinearLayout ll_data;
    List<String> list = new ArrayList<String>();
    int it = android.text.InputType.TYPE_CLASS_TEXT;
    int hint = 0;

    // Typen setzen:
    List<Integer> list_number = new ArrayList<Integer>();

    for (int i = 0; i < array_en_type.length; i++) {
      if (array_en_type[i].equals(type)) {
        list_number.add(i);
      }
    }

    for (int i = 0; i < list_number.size(); i++) {
      list.add((array_en_name[list_number.get(i)]));
    }

    final String[] spinnerArray = list.toArray(new String[list.size()]);

    // -----------

    LinearLayout ll_telephone =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_telephone);
    LinearLayout ll_email =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_email);
    LinearLayout ll_other =
        (LinearLayout) my_contact_view.findViewById(R.id.mycontact_ll_data_other);

    // new row
    LinearLayout row = new LinearLayout(this);
    row.setOrientation(LinearLayout.HORIZONTAL);

    DisplayMetrics tmp_metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(tmp_metrics);
    int resolution_width = tmp_metrics.widthPixels;

    final boolean large_screen = (resolution_width >= 720);

    final EditText et = new EditText(this);
    LayoutParams lp_et;
    lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT, 1);

    if (type.equals("number")) {
      ll_data = ll_telephone;

      it = InputType.TYPE_CLASS_PHONE;

      hint = R.string.telephone;

    } else if (type.equals("email")) {
      ll_data = ll_email;

      it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;

      hint = R.string.email;

    } else {
      ll_data = ll_other;

      if (type.equals("address")) {

        et.setMinLines(1);
        et.setMaxLines(3);
        et.setLines(2);

        hint = R.string.address;
        it =
            InputType.TYPE_CLASS_TEXT
                | InputType
                    .TYPE_TEXT_FLAG_MULTI_LINE; // android.text.InputType.TYPE_TEXT_VARIATION_POSTAL_ADDRESS;
        lp_et = new LayoutParams(LayoutParams.WRAP_CONTENT, large_screen ? 130 : 90, 1);

        row.setLayoutParams(
            new LayoutParams(LayoutParams.MATCH_PARENT, (large_screen ? 130 : 90) + 20));

        et.setImeOptions(EditorInfo.IME_FLAG_NO_ENTER_ACTION);
        // et.setGravity(Gravity.LEFT | Gravity.TOP );

      } else if (type.equals("website")) {
        hint = R.string.website;
        it = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      }
    }

    ((LinearLayout) ll_data.getParent()).setVisibility(LinearLayout.VISIBLE);

    et.setTextSize(large_screen ? 16 : 14); // EditText-Textgr��e
    et.setEms(10);
    et.setHint(hint);

    et.setInputType(it);

    lp_et.setMargins(0, 3, 0, 0);
    et.setLayoutParams(lp_et);

    Spinner spinner = new Spinner(this);
    LayoutParams lp_spinner =
        new LayoutParams(
            large_screen ? Functions.dpsToPx(this, 100) : Functions.dpsToPx(this, 80), /*300 : 200*/
            LayoutParams.MATCH_PARENT);

    lp_spinner.setMargins(0, 3, 0, 0);

    MySpinnerArrayAdapter dataAdapter = new MySpinnerArrayAdapter(this, list, large_screen);

    dataAdapter.setDropDownViewResource(
        android.support.v7.appcompat.R.layout.support_simple_spinner_dropdown_item);

    spinner.setAdapter(dataAdapter);
    spinner.setLayoutParams(lp_spinner);

    spinner.setOnItemSelectedListener(
        new OnItemSelectedListener() {

          @Override
          public void onItemSelected(
              final AdapterView<?> adapterView, final View view, int arg2, long arg3) {
            final Spinner spinner = (Spinner) adapterView;
            MySpinnerArrayAdapter adapter = (MySpinnerArrayAdapter) spinner.getAdapter();
            if (adapter
                .getItem(arg2)
                .toLowerCase(new Locale("en"))
                .equals(getString(R.string.en_custom).toLowerCase(new Locale("en")))) {

              LinearLayout ll = new LinearLayout(MainActivity.this);
              final EditText et = new EditText(MainActivity.this);

              LinearLayout.LayoutParams layoutParams =
                  new LinearLayout.LayoutParams(
                      LinearLayout.LayoutParams.MATCH_PARENT,
                      LinearLayout.LayoutParams.WRAP_CONTENT);
              layoutParams.setMargins(0, 20, 0, 0);

              et.setTextColor(Color.BLACK);
              et.requestFocus();

              // et.setHint(R.string.place);

              ll.addView(et, layoutParams);

              AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
              builder
                  .setView(ll)
                  .setTitle(R.string.message_custom_en)
                  .setPositiveButton(
                      android.R.string.ok,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {

                          String[] newItems = new String[spinnerArray.length + 1];
                          System.arraycopy(spinnerArray, 0, newItems, 0, spinnerArray.length);
                          newItems[newItems.length - 1] = et.getText().toString();

                          MySpinnerArrayAdapter adapter =
                              new MySpinnerArrayAdapter(
                                  getApplicationContext(),
                                  newItems,
                                  ((MySpinnerArrayAdapter) spinner.getAdapter()).getLargeScreen());
                          spinner.setAdapter(adapter);
                          spinner.setSelection(newItems.length - 1);
                        }
                      })
                  .setNegativeButton(
                      android.R.string.cancel,
                      new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {}
                      })
                  .create()
                  .show();
            }
          }

          @Override
          public void onNothingSelected(AdapterView<?> arg0) {
            // TODO Auto-generated method stub

          }
        });

    Button btn = new Button(this);
    btn.setText("x");
    LayoutParams lp_btn = new LayoutParams(Functions.dpsToPx(this, 32), LayoutParams.WRAP_CONTENT);
    lp_btn.setMargins(-10, 0, -10, 0);
    btn.setLayoutParams(lp_btn);
    btn.setBackgroundColor(Color.TRANSPARENT);

    btn.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            if (((LinearLayout) v.getParent().getParent()).getChildCount() == 1) {
              ((LinearLayout) v.getParent().getParent().getParent()).setVisibility(View.GONE);
            }
            ((LinearLayout) v.getParent().getParent()).removeView((LinearLayout) v.getParent());
          }
        });

    row.addView(et);
    row.addView(spinner);
    row.addView(btn);

    row.setTag(type);

    ll_data.addView(row);
  }
  public void addIntoScrollView(int i) {
    LinearLayout.LayoutParams mainParam =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    LinearLayout mainLayout = new LinearLayout(this);
    mainLayout.setOrientation(LinearLayout.VERTICAL);
    mainLayout.setLayoutParams(mainParam);
    mainParam.setMargins(0, 0, 0, pixMainEnd);
    // mainLayout.setBackgroundColor(getResources().getColor(R.color.blue));
    LinearLayout.LayoutParams coverForImageParam =
        new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout coverForImageLayout = new LinearLayout(this);
    coverForImageLayout.setLayoutParams(coverForImageParam);
    coverForImageLayout.setPadding(0, 2, 0, 2);
    coverForImageLayout.setBackgroundColor(getResources().getColor(R.color.black));

    LinearLayout.LayoutParams imageParam = new LayoutParams(LayoutParams.MATCH_PARENT, imagePixel);

    FrameLayout frameLayout;
    FrameLayout.LayoutParams frameParams =
        new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    frameLayout = new FrameLayout(this);
    frameLayout.setLayoutParams(frameParams);

    sellerImage = new ImageView(this);

    LayoutParams videoParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    // videoParams.setMargins(0, 0, 0, pixMainEnd);
    RelativeLayout videoRelative = new RelativeLayout(this);
    videoRelative.setLayoutParams(videoParams);

    if (tempSellList.get(i).getThumbnailLocation().equals("null")) {
      // sellerImage.setBackgroundResource(R.drawable.buy_sell_trade_5);
      sellerImage.setLayoutParams(imageParam);
      coverForImageLayout.addView(sellerImage);
      addAndroidUniversalImageLoader(sellerImage, tempSellList.get(i).getLocation());
      //            addImageUrlPicasso(sellerImage, tempSellList.get(i).getLocation(),
      //                    pixFullWidth, imagePixel);
      frameLayout.addView(coverForImageLayout);
      clickView(
          sellerImage,
          tempSellList.get(i).getLocation(),
          "",
          false,
          false,
          tempSellList.get(i).getSkillId());
    } else {
      RelativeLayout.LayoutParams relParam =
          new RelativeLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, imagePixel);
      relParam.addRule(RelativeLayout.CENTER_HORIZONTAL);
      sellerImage.setLayoutParams(relParam);
      addAndroidUniversalImageLoader(sellerImage, tempSellList.get(i).getThumbnailLocation());
      //            addImageUrlPicasso(sellerImage, tempSellList.get(i)
      //                            .getThumbnailLocation(),
      //                    pixFullWidth, imagePixel);

      LayoutParams videoRelativeParam =
          new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
      videoRelativeParam.setMargins(0, 0, 0, 0);
      RelativeLayout relativeLayout = new RelativeLayout(this);
      relativeLayout.setLayoutParams(videoRelativeParam);

      ImageView imgVideoIcon = new ImageView(this);
      imgVideoIcon.setBackgroundResource(R.drawable.ic_action_video);
      RelativeLayout.LayoutParams rp =
          new RelativeLayout.LayoutParams(
              ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
      rp.addRule(RelativeLayout.CENTER_HORIZONTAL);
      rp.addRule(RelativeLayout.CENTER_VERTICAL);
      imgVideoIcon.setLayoutParams(rp);

      coverForImageLayout.addView(sellerImage);
      relativeLayout.addView(coverForImageLayout);
      relativeLayout.addView(imgVideoIcon);

      // frameLayout.setBackgroundColor(getResources().getColor(R.color.green));
      frameLayout.addView(relativeLayout);
      clickView(
          sellerImage,
          tempSellList.get(i).getThumbnailLocation(),
          tempSellList.get(i).getVideoLocation(),
          true,
          true,
          tempSellList.get(i).getSkillId());
    }

    LinearLayout.LayoutParams txtCombineParam =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    LinearLayout textCombineLayout = new LinearLayout(this);
    textCombineLayout.setLayoutParams(txtCombineParam);

    LayoutParams testParams;
    testParams =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    testParams.setMargins(0, pixTopFrame, 0, 0);
    LinearLayout innerFortextCombineLayout = new LinearLayout(this);
    innerFortextCombineLayout.setLayoutParams(testParams);

    LinearLayout.LayoutParams txtParam =
        new LinearLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f);
    TextView txtName = new TextView(this);
    txtName.setTextColor(getResources().getColor(R.color.black));
    txtName.setTextSize(20);
    txtName.setGravity(Gravity.BOTTOM);
    txtName.setText(tempSellList.get(i).getName());
    txtName.setPadding(pixProfileRight, 0, 0, 0);
    clickTextView(txtName, tempSellList.get(i).getSkillId());
    innerFortextCombineLayout.addView(txtName, txtParam);

    LinearLayout.LayoutParams profileImageParam = new LayoutParams(profilePixel, profilePixel);
    profileImageParam.setMargins(0, 0, pixProfileRight, 0);
    RoundedImageView profileImage = new RoundedImageView(this);
    addAndroidUniversalImageLoader(profileImage, tempSellList.get(i).getProfilePicture());

    sellProfileClick(profileImage, tempSellList.get(i).getStkid());
    profileImage.setLayoutParams(profileImageParam);

    innerFortextCombineLayout.addView(profileImage);
    textCombineLayout.addView(innerFortextCombineLayout);
    frameLayout.addView(textCombineLayout);
    mainLayout.addView(frameLayout);
    scrollLayout.addView(mainLayout);
  }
示例#15
0
  @Override
  public View getView() throws ElementFailureException {
    if (elementView != null) return elementView;

    LinearLayout v = new LinearLayout(Utils.mainActivity);
    v.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    v.setOrientation(LinearLayout.VERTICAL);
    elementView = v;

    /** Nesting another element's view in our own for title and description. */
    LinearLayout descriptionFrame = new LinearLayout(Utils.mainActivity);
    LayoutParams dfl = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    descriptionFrame.setOrientation(LinearLayout.VERTICAL);
    final int leftMargin = (int) (2 * Utils.density + 0.5f);
    dfl.setMargins(leftMargin, 0, 0, 0);
    descriptionFrame.setLayoutParams(dfl);
    elementView.addView(descriptionFrame);

    if (titleObj != null) {
      TextView titleView = (TextView) titleObj.getView();
      titleView.setBackground(null);
      descriptionFrame.addView(titleView);
    }

    if (descriptionObj != null) descriptionFrame.addView(descriptionObj.getView());

    textView = new TextView(Utils.mainActivity);
    textView.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    textView.setGravity(Gravity.CENTER);
    textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
    textView.setTextColor(Color.parseColor("#AAAAAA"));
    textView.setId(tv_id);
    elementView.addView(textView);

    v.setOnLongClickListener(this);
    textView.setOnLongClickListener(this);

    elementFrame = new LinearLayout(Utils.mainActivity);
    elementFrame.setLayoutParams(
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    elementFrame.setOrientation(LinearLayout.VERTICAL);

    selectorFrame = new FrameLayout(Utils.mainActivity);
    LayoutParams sfl =
        new LayoutParams((int) (15 * Utils.density + 0.5f), LayoutParams.MATCH_PARENT);
    int margin = (int) (Utils.density + 0.5f);
    sfl.setMargins(0, margin, 0, margin);
    selectorFrame.setLayoutParams(sfl);

    selectorFrame.setBackgroundColor(Color.DKGRAY);
    selectorFrame.setVisibility(View.GONE);

    elementFrame.addView(selectorFrame);
    elementFrame.addView(v);

    elementView = elementFrame;

    String initialLive = getLiveValue();
    if (getStoredValue() == null) {
      Utils.db.setValue(command, initialLive);
      stored = lastLive;
    }

    lastEdit = lastLive;

    if (original == null) original = lastLive;

    textView.setOnClickListener(this);
    textView.setText(lastLive.toString());

    valueCheck();

    return elementView;
  }
示例#16
0
 private void setViewMargins(View view, int left, int top, int right, int bottom) {
   LayoutParams params = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   params.setMargins(left, top, right, bottom);
   view.setLayoutParams(params);
 }
  private void initScrollView() {
    // 初始化滚动条(加载二十张图片的广告)
    // 获取屏幕的宽度
    DisplayMetrics dm = new DisplayMetrics();
    // 取得窗口属性
    getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
    // 窗口的宽度
    int screenWidth = dm.widthPixels;
    int newWidth = screenWidth / 3;
    LayoutParams params = new LayoutParams(newWidth, LayoutParams.WRAP_CONTENT);
    params.setMargins(0, 0, 5, 0);
    list = bean3.hotcommodity;
    if (bean3 != null && list != null) {

      if (list.size() > 0) {
        category_line.setVisibility(View.VISIBLE);
      } else {
        category_line.setVisibility(View.GONE);
      }

      if (list.size() > 3) {
        jianbian_left_iv.setVisibility(View.VISIBLE);
        jianbian_right_iv.setVisibility(View.VISIBLE);
      } else {
        jianbian_left_iv.setVisibility(View.GONE);
        jianbian_right_iv.setVisibility(View.GONE);
      }

      // 按价格的升序排列
      Collections.sort(
          list,
          new Comparator<Hotcommodity>() {

            @Override
            public int compare(Hotcommodity hot1, Hotcommodity hot2) {
              double price1 = Double.parseDouble(MathUtil.priceForAppWithOutSign(hot1.PRICE));
              double price2 = Double.parseDouble(MathUtil.priceForAppWithOutSign(hot2.PRICE));

              if (price1 == price2) {
                return 0;
              }
              if (price1 > price2) {
                return 1;
              } else {
                return -1;
              }
            }
          });

      // 引入一个布局
      for (int i = 0; i < list.size(); i++) {
        final int count = i;
        View v =
            LayoutInflater.from(getActivity())
                .inflate(R.layout.class_list_level3_ll_for_scrollview, null);
        ImageView img = (ImageView) v.findViewById(R.id.class_list_level3_forviewpager_img);
        TextView name = (TextView) v.findViewById(R.id.class_list_level3_forviewpager_name);
        TextView price = (TextView) v.findViewById(R.id.class_list_level3_forviewpager_price);

        if (list.get(i).equals("") || list.get(i) == null) {
          return;
        } else {
          ImageManager.LoadWithServer(list.get(i).COMMODITY_IMAGE_PATH, img);
        }
        if (list.get(i).COMMODITY_NAME != null && !list.get(i).COMMODITY_NAME.equals("")) {

          // 加\n是为了防止名称显示一行后,所有价格不在同一条线上,显示比较丑陋
          name.setText(list.get(i).COMMODITY_NAME + "\n");
        } else {
          name.setText("\n\n");
        }
        if (list.get(i).PRICE != null && !list.get(i).PRICE.equals("")) {
          price.setText(MathUtil.priceForAppWithSign(list.get(i).PRICE));
        } else {
          price.setText(MathUtil.priceForAppWithSign(0));
        }

        class_list_level3_forviewpager_load =
            (LinearLayout) v.findViewById(R.id.class_list_level3_forviewpager_load);
        class_list_level3_forviewpager_load.setLayoutParams(params);
        class_list_level3_forviewpager_load.setOnClickListener(
            new OnClickListener() {

              @Override
              public void onClick(View arg0) {
                Intent intent = new Intent(getActivity(), ProductsDetailActivity.class);
                if (list.get(count).ID != null && !list.get(count).ID.equals("")) {
                  intent.putExtra(ProductsDetailActivity.BUNDLE_KEY_GOODS_ID, list.get(count).ID);
                  Log.i(TAG, list.get(count).ID + "三级分类列表的热销商品的ID");
                  startActivity(intent);
                } else {
                  return;
                }
              }
            });
        class_list_level3_load.addView(v);
      }
    } else {
      return;
    }
  }
  protected void createView() {

    Display display = this.getWindow().getWindowManager().getDefaultDisplay();
    Point size = new Point();

    if (Build.VERSION.SDK_INT > 12) {
      display.getSize(size);
    } else {
      size.y = display.getHeight();
      size.x = display.getWidth();
    }

    int width_times = Math.round((float) size.x / (56.0f * density));
    float dialog_width = ((float) (width_times - 1) * 56.0f * density);

    // add a view to margin the space
    LayoutParams mvParams = new LayoutParams((int) dialog_width, LayoutParams.WRAP_CONTENT);
    LinearLayout messageView = new LinearLayout(this.getContext());
    messageView.setLayoutParams(mvParams);
    messageView.setPadding(view_padding, view_padding, view_padding, view_padding);
    messageView.setGravity(Gravity.TOP | Gravity.CENTER);
    messageView.setOrientation(LinearLayout.VERTICAL);

    // icon
    LayoutParams iconParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    iconParams.setMargins(0, 0, 0, view_margin);
    iconParams.gravity = Gravity.CENTER;
    ImageView icon = new ImageView(this.getContext());
    icon.setLayoutParams(iconParams);
    icon.setId(android.R.id.icon);
    icon.setVisibility(View.GONE);

    // title
    LayoutParams titleParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    titleParams.setMargins(0, 0, 0, view_margin);
    TextView title = new TextView(this.getContext());
    title.setLayoutParams(titleParams);
    title.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark));
    title.setTextSize(20);
    title.setTypeface(null, Typeface.BOLD);
    title.setId(android.R.id.title);
    title.setVisibility(View.GONE);

    // message
    LayoutParams msgParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    TextView message = new TextView(this.getContext());
    message.setLayoutParams(msgParams);
    message.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark));
    message.setTextSize(18);
    message.setId(android.R.id.message);
    message.setVisibility(View.GONE);

    // optional choice
    LayoutParams checkBoxParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    checkBoxParams.setMargins(0, view_margin, 0, 0);
    CheckBox checkBox = new CheckBox(this.getContext());
    checkBox.setLayoutParams(checkBoxParams);
    checkBox.setId(android.R.id.checkbox);
    checkBox.setTextColor(this.getContext().getResources().getColor(R.color.text_color_dark));
    checkBox.setVisibility(View.GONE);

    // add elements to body view
    messageView.addView(icon);
    messageView.addView(title);
    messageView.addView(message);
    messageView.addView(checkBox);

    // button area
    LayoutParams btnsParams = new LayoutParams((int) dialog_width, (int) (52.0f * density));
    LinearLayout buttons = new LinearLayout(this.getContext());
    buttons.setMinimumHeight((int) (52.0f * density));
    buttons.setLayoutParams(btnsParams);
    buttons.setGravity(Gravity.RIGHT | Gravity.CENTER);
    buttons.setId(android.R.id.extractArea);
    buttons.setPadding(0, 0, (int) (8.0f * density), 0);

    contentView.addView(messageView);
    contentView.addView(buttons);

    this.setContentView(contentView);
  }