예제 #1
0
 public MainFrame(Context context) {
   super(context);
   final TextView text1 = new TextView(context);
   addView(text1);
   text1.setId(android.R.id.text1);
   final TextView text2 = new TextView(context);
   text2.setId(android.R.id.text2);
   addView(text2);
   ViewInjector.inject(this, this);
 }
  @Before
  public void setUp() throws Exception {
    Activity context = Robolectric.buildActivity(Activity.class).create().get();
    relativeLayout = new RelativeLayout(context);
    relativeLayout.setId((int) Utils.generateUniqueId());
    viewGroup = new LinearLayout(context);

    BaseForwardingNativeAd baseForwardingNativeAd = new BaseForwardingNativeAd() {};
    baseForwardingNativeAd.setTitle("test title");
    baseForwardingNativeAd.setText("test text");
    baseForwardingNativeAd.setCallToAction("test call to action");
    baseForwardingNativeAd.setClickDestinationUrl("destinationUrl");

    nativeResponse =
        new NativeResponse(
            context,
            "impressionTrackerUrl",
            "clickTrackerUrl",
            "test ID",
            baseForwardingNativeAd,
            mock(MoPubNative.MoPubNativeListener.class));

    titleView = new TextView(context);
    titleView.setId((int) Utils.generateUniqueId());
    textView = new TextView(context);
    textView.setId((int) Utils.generateUniqueId());
    callToActionView = new Button(context);
    callToActionView.setId((int) Utils.generateUniqueId());
    mainImageView = new ImageView(context);
    mainImageView.setId((int) Utils.generateUniqueId());
    iconImageView = new ImageView(context);
    iconImageView.setId((int) Utils.generateUniqueId());
    badView = new ImageView(context);
    badView.setId((int) Utils.generateUniqueId());

    relativeLayout.addView(titleView);
    relativeLayout.addView(textView);
    relativeLayout.addView(callToActionView);
    relativeLayout.addView(mainImageView);
    relativeLayout.addView(iconImageView);
    relativeLayout.addView(badView);

    viewBinder =
        new ViewBinder.Builder(relativeLayout.getId())
            .titleId(titleView.getId())
            .textId(textView.getId())
            .callToActionId(callToActionView.getId())
            .mainImageId(mainImageView.getId())
            .iconImageId(iconImageView.getId())
            .build();

    subject = new MoPubNativeAdRenderer(viewBinder);
  }
  public BearingWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);

    setOrientation(LinearLayout.VERTICAL);

    TableLayout.LayoutParams params = new TableLayout.LayoutParams();
    params.setMargins(7, 5, 7, 5);

    mGetBearingButton = new Button(getContext());
    mGetBearingButton.setId(QuestionWidget.newUniqueId());
    mGetBearingButton.setPadding(20, 20, 20, 20);
    mGetBearingButton.setText(getContext().getString(R.string.get_bearing));
    mGetBearingButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    mGetBearingButton.setEnabled(!prompt.isReadOnly());
    mGetBearingButton.setLayoutParams(params);
    if (prompt.isReadOnly()) {
      mGetBearingButton.setVisibility(View.GONE);
    }

    mStringAnswer = new TextView(getContext());
    mStringAnswer.setId(QuestionWidget.newUniqueId());

    mAnswerDisplay = new TextView(getContext());
    mAnswerDisplay.setId(QuestionWidget.newUniqueId());
    mAnswerDisplay.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    mAnswerDisplay.setGravity(Gravity.CENTER);

    String s = prompt.getAnswerText();
    if (s != null && !s.equals("")) {
      mGetBearingButton.setText(getContext().getString(R.string.replace_bearing));
      setBinaryData(s);
    }

    // when you press the button
    mGetBearingButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            Collect.getInstance()
                .getActivityLogger()
                .logInstanceAction(this, "recordBearing", "click", mPrompt.getIndex());
            Intent i = null;
            i = new Intent(getContext(), BearingActivity.class);

            Collect.getInstance().getFormController().setIndexWaitingForData(mPrompt.getIndex());
            ((Activity) getContext()).startActivityForResult(i, FormEntryActivity.BEARING_CAPTURE);
          }
        });

    addView(mGetBearingButton);
    addView(mAnswerDisplay);
  }
예제 #4
0
  public boolean addViews(
      String type,
      RelativeLayout layout,
      Map<String, Float> list,
      String previous,
      String relativeLeft,
      String relativeRight) {
    // add or modify
    RelativeLayout.LayoutParams leftLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    RelativeLayout.LayoutParams rightLayoutParams =
        new RelativeLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    for (Map.Entry<String, Float> listElement : list.entrySet()) {
      // key and value become textviews
      String rightChild = type + listElement.getValue() + "_id";
      int resourceID = this.findResource(rightChild, null, null);
      if (resourceID != 0) {
        TextView value = (TextView) findViewById(resourceID);
        value.setText(listElement.getValue().toString());
        continue;
      }

      TextView value = new TextView(this);
      value.setText(listElement.getValue().toString());
      value.setId(resourceID);

      String leftChild = type + listElement.getKey() + "_id";
      resourceID = this.findResource(leftChild, null, null);
      TextView key = new TextView(this);
      key.setText(listElement.getKey());
      key.setId(resourceID);

      leftLayoutParams.addRule(RelativeLayout.BELOW, this.findResource(previous, null, null));
      leftLayoutParams.addRule(
          RelativeLayout.ALIGN_LEFT, this.findResource(relativeLeft, null, null));

      rightLayoutParams.addRule(RelativeLayout.ALIGN_TOP, this.findResource(leftChild, null, null));
      rightLayoutParams.addRule(
          RelativeLayout.ALIGN_LEFT, this.findResource(relativeRight, null, null));

      layout.addView(key, leftLayoutParams);
      layout.addView(value, rightLayoutParams);

      previous = leftChild;
    }
    return true;
  }
  private void addWeightElement() {
    //        currentItemsCnt++;
    WeightItem item = new WeightItem();
    item.position = helper.itemsList.size();
    item.weight = 100 / currentItemsCnt;
    helper.itemsList.add(item);

    TextView text = new TextView(this);
    text.setText("pos" + item.position);

    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.weight = item.weight;
    text.setLayoutParams(params);
    text.setId(0x00001000 + item.position);
    text.setBackgroundColor(
        Color.rgb(
            0xFF / (item.position + 1), 0x7F / (item.position + 1), 0xFF / (item.position + 1)));
    weightView.addView(text);

    // Liean container

    TextView seekText = new TextView(this);
    seekText.setText("pos " + item.position);
    seekText.setPadding(0, 0, 10, 0);
    SeekBar seekBar = new SeekBar(this);
    seekBar.setId(0x00001000 + item.position + 30);
    seekBar.setMax(100 / currentItemsCnt);
    seekBar.setOnSeekBarChangeListener(new SeekListener(item));
    seekBar.setPadding(0, 5, 0, 5);
    seekBar.setProgress(seekBar.getMax());

    LinearLayout linearLayout = new LinearLayout(this);
    //            LinearLayout.LayoutParams params = new
    // LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
    //                    ViewGroup.LayoutParams.WRAP_CONTENT);
    seekBar.setLayoutParams(params);
    linearLayout.addView(seekText);
    linearLayout.addView(seekBar);

    seekView.addView(linearLayout);

    TextView ttt = new TextView(this);

    ttt.setId(0x00002000 + item.position);
    ttt.setText("weight of item " + item.position + " w = " + item.weight);
    changeView.addView(ttt);
  }
예제 #6
0
  private TextView initializeTextView(final Resources resources) {
    TextView text = new TextView(this.activity);
    text.setId(TEXT_ID);
    text.setText(this.text);
    //        text.setTypeface(Typeface.DEFAULT_BOLD);
    text.setGravity(this.style.gravity);

    // set the text color if set
    if (this.style.textColorValue != Style.NOT_SET) {
      text.setTextColor(this.style.textColorValue);
    } else if (this.style.textColorResourceId != 0) {
      text.setTextColor(resources.getColor(this.style.textColorResourceId));
    }

    // Set the text size. If the user has set a text size and text
    // appearance, the text size in the text appearance
    // will override this.
    if (this.style.textSize != 0) {
      text.setTextSize(TypedValue.COMPLEX_UNIT_SP, this.style.textSize);
    }

    // Setup the shadow if requested
    if (this.style.textShadowColorResId != 0) {
      initializeTextViewShadow(resources, text);
    }

    // Set the text appearance
    if (this.style.textAppearanceResId != 0) {
      text.setTextAppearance(this.activity, this.style.textAppearanceResId);
    }
    return text;
  }
예제 #7
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    View linearLayout = findViewById(R.id.info);
    // LinearLayout layout = (LinearLayout) findViewById(R.id.info);

    TextView valueTV = new TextView(this);
    valueTV.setText("hallo hallo");
    valueTV.setId(Integer.parseInt("4"));
    valueTV.setLayoutParams(
        new ActionBar.LayoutParams(
            ActionBar.LayoutParams.FILL_PARENT, ActionBar.LayoutParams.WRAP_CONTENT));

    ((LinearLayout) linearLayout).addView(valueTV);
    // we will using AsyncTask during parsing
    DisplayMetrics displaymetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
    int height = displaymetrics.heightPixels;
    int width = displaymetrics.widthPixels;
    // String
    // host="http://10.0.2.2:81/index.php?os=android&screen_size_height="+Integer.toString(height)+"&screen_size_width="+Integer.toString(width);
    String host =
        "http://192.168.0.109:81/index.php?os=android&screen_size_height="
            + Integer.toString(height)
            + "&screen_size_width="
            + Integer.toString(width);
    new AsyncTaskParseJson().execute(host);
  }
  /**
   * Provide default implementation to return a simple list view. Subclasses can override to replace
   * with their own layout. If doing so, the returned view hierarchy <em>must</em> have a ListView
   * whose id is {@link android.R.id#list android.R.id.list} and can optionally have a sibling view
   * id {@link android.R.id#empty android.R.id.empty} that is to be shown when the list is empty.
   *
   * <p>If you are overriding this method with your own custom content, consider including the
   * standard layout {@link android.R.layout#list_content} in your layout file, so that you continue
   * to retain all of the standard behavior of ListFragment. In particular, this is currently the
   * only way to have the built-in indeterminant progress state be shown.
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    FrameLayout root = new FrameLayout(getActivity());

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    root.addView(
        tv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    ListView lv = new ListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    root.addView(
        lv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    ListView.LayoutParams lp =
        new ListView.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    root.setLayoutParams(lp);

    return root;
  }
예제 #9
0
  /**
   * Provide default implementation to return a simple list view. Subclasses can override to replace
   * with their own layout. If doing so, the returned view hierarchy <em>must</em> have a
   * ExpandableListView whose id is {@link android.R.id#list android.R.id.list} and can optionally
   * have a sibling view id {@link android.R.id#empty android.R.id.empty} that is to be shown when
   * the list is empty.
   *
   * <p>If you are overriding this method with your own custom content, consider including the
   * standard layout {@link android.R.layout#list_content} in your layout file, so that you continue
   * to retain all of the standard behavior of ListFragment. In particular, this is currently the
   * only way to have the built-in indeterminant progress state be shown.
   */
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = getActivity();

    FrameLayout root = new FrameLayout(context);

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

    LinearLayout pframe = new LinearLayout(context);
    pframe.setId(INTERNAL_PROGRESS_CONTAINER_ID);
    pframe.setOrientation(LinearLayout.VERTICAL);
    pframe.setVisibility(View.GONE);
    pframe.setGravity(Gravity.CENTER);

    ProgressBar progress = new ProgressBar(context, null, android.R.attr.progressBarStyleLarge);
    pframe.addView(
        progress,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));

    root.addView(
        pframe,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

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

    FrameLayout lframe = new FrameLayout(context);
    lframe.setId(INTERNAL_LIST_CONTAINER_ID);

    TextView tv = new TextView(getActivity());
    tv.setId(INTERNAL_EMPTY_ID);
    tv.setGravity(Gravity.CENTER);
    lframe.addView(
        tv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    ExpandableListView lv = new ExpandableListView(getActivity());
    lv.setId(android.R.id.list);
    lv.setDrawSelectorOnTop(false);
    lframe.addView(
        lv,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    root.addView(
        lframe,
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

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

    root.setLayoutParams(
        new FrameLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT));

    return root;
  }
  /**
   * Add a Views containing the question text, audio (if applicable), and image (if applicable). To
   * satisfy the RelativeLayout constraints, we add the audio first if it exists, then the TextView
   * to fit the rest of the space, then the image if applicable.
   */
  protected void addQuestionText(FormEntryPrompt p) {
    String imageURI = p.getImageText();
    String audioURI = p.getAudioText();
    String videoURI = p.getSpecialFormQuestionText("video");

    // shown when image is clicked
    String bigImageURI = p.getSpecialFormQuestionText("big-image");

    String promptText = p.getLongText();
    // Add the text view. Textview always exists, regardless of whether there's text.
    mQuestionText = new TextView(getContext());
    mQuestionText.setText(promptText == null ? "" : promptText);
    mQuestionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize);
    mQuestionText.setTypeface(null, Typeface.BOLD);
    mQuestionText.setPadding(0, 0, 0, 7);
    mQuestionText.setId(QuestionWidget.newUniqueId()); // assign random id

    // Wrap to the size of the parent view
    mQuestionText.setHorizontallyScrolling(false);

    if (promptText == null || promptText.length() == 0) {
      mQuestionText.setVisibility(GONE);
    }

    // Create the layout for audio, image, text
    mediaLayout = new MediaLayout(getContext());
    mediaLayout.setAVT(p.getIndex(), "", mQuestionText, audioURI, imageURI, videoURI, bigImageURI);

    addView(mediaLayout, mLayout);
  }
    // Override QuestionWidget's add question text. Build it the same
    // but add it to the questionLayout
    protected void addQuestionText(FormEntryPrompt p) {

        // Add the text view. Textview always exists, regardless of whether there's text.
    	TextView questionText = new TextView(getContext());
        questionText.setText(p.getLongText());
        questionText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mQuestionFontsize);
        questionText.setTypeface(null, Typeface.BOLD);
        questionText.setPadding(0, 0, 0, 7);
        questionText.setId(QuestionWidget.newUniqueId()); // assign random id

        // Wrap to the size of the parent view
        questionText.setHorizontallyScrolling(false);

        if (p.getLongText() == null) {
            questionText.setVisibility(GONE);
        }

        // Put the question text on the left half of the screen
        LinearLayout.LayoutParams labelParams =
            new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
        labelParams.weight = 1;

        questionLayout = new LinearLayout(getContext());
        questionLayout.setOrientation(LinearLayout.HORIZONTAL);

        questionLayout.addView(questionText, labelParams);
    }
  public HierarchyElementView(Context context, HierarchyElement it) {
    super(context);

    setColor(it.getColor());

    mIcon = new ImageView(context);
    mIcon.setImageDrawable(it.getIcon());
    mIcon.setId(1);
    mIcon.setPadding(0, 15, 5, 0);
    addView(
        mIcon,
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));

    mPrimaryTextView = new TextView(context);
    mPrimaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Large);
    mPrimaryTextView.setText(it.getPrimaryText());
    mPrimaryTextView.setPadding(0, 7, 0, 0);
    mPrimaryTextView.setId(2);
    LayoutParams l =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    l.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mPrimaryTextView, l);

    mSecondaryTextView = new TextView(context);
    mSecondaryTextView.setText(it.getSecondaryText());
    mSecondaryTextView.setPadding(0, 0, 0, 7);
    mSecondaryTextView.setTextAppearance(context, android.R.style.TextAppearance_Small);
    LayoutParams lp =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    lp.addRule(RelativeLayout.BELOW, mPrimaryTextView.getId());
    lp.addRule(RelativeLayout.RIGHT_OF, mIcon.getId());
    addView(mSecondaryTextView, lp);
  }
예제 #13
0
  private RelativeLayout createPin() {
    final RelativeLayout pinLayout = new RelativeLayout(getContext());
    pinLayout.setVisibility(View.INVISIBLE);

    final Pin pin = new Pin(getContext());
    pin.setId(ID_PIN);
    final RelativeLayout.LayoutParams pinParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    pinParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
    pinParams.addRule(RelativeLayout.ALIGN_BOTTOM, ID_PIN_TEXT);
    pinParams.addRule(RelativeLayout.ALIGN_TOP, ID_PIN_TEXT);
    pin.setLayoutParams(pinParams);
    pinLayout.addView(pin);

    final TextView indicatorTextView = new TextView(getContext());
    indicatorTextView.setId(ID_PIN_TEXT);
    final RelativeLayout.LayoutParams indicatorParams =
        new RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    indicatorParams.addRule(RelativeLayout.LEFT_OF, ID_PIN);
    indicatorTextView.setLayoutParams(indicatorParams);
    indicatorTextView.setTextColor(Color.WHITE);
    indicatorTextView.setGravity(Gravity.CENTER);
    indicatorTextView.setBackgroundColor(GREY_LIGHT);
    pinLayout.addView(indicatorTextView);

    return pinLayout;
  }
예제 #14
0
 public void addItem(Item item) {
   int size = icon + padding + padding;
   ViewGroup.LayoutParams params =
       new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, size);
   TextView row = new TextView(getContext());
   row.setId(item.getId());
   row.setLayoutParams(params);
   row.setMaxLines(1);
   row.setEllipsize(TextUtils.TruncateAt.END);
   row.setGravity(Gravity.CENTER_VERTICAL);
   row.setText(item.getTitle());
   row.setTypeface(Typeface.DEFAULT_BOLD);
   row.setOnClickListener(this);
   row.setTextColor(BottomUtils.colorStateListText(getContext()));
   TypedValue typedValue = new TypedValue();
   getContext()
       .getTheme()
       .resolveAttribute(android.R.attr.selectableItemBackground, typedValue, true);
   row.setBackgroundResource(typedValue.resourceId);
   if (item.getIcon() != null) {
     row.setCompoundDrawablesWithIntrinsicBounds(icon(item.getIcon()), null, null, null);
     row.setCompoundDrawablePadding(padding);
     row.setPadding(padding, padding, padding, padding);
   } else {
     row.setPadding(size, padding, padding, padding);
   }
   container.addView(row);
 }
          @Override
          public void run() {

            if (mVisible) {
              Canvas canvas = mHolder.lockCanvas();
              WidgetGroup group = new WidgetGroup(getApplicationContext());
              group.setBackgroundColor(Color.WHITE);
              group.setLayoutParams(
                  new LinearLayout.LayoutParams(
                      ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
              group.setAddStatesFromChildren(true);
              group.layout(0, 0, mWidth, mHeight);

              String result =
                  Build.MANUFACTURER
                      + " "
                      + Build.VERSION.RELEASE
                      + " "
                      + DeviceName.getDeviceName();
              TextView osVersion = new TextView(getApplicationContext());
              osVersion.setTextColor(Color.BLACK);
              osVersion.setTextSize(80.f);
              osVersion.setText(result);
              osVersion.setId(R.id.os_version);

              osVersion.layout(0, 0, mWidth, mHeight);
              group.addView(osVersion);

              group.draw(canvas);
              getSurfaceHolder().unlockCanvasAndPost(canvas);
              mHandler.removeCallbacks(draw);
              mHandler.postDelayed(draw, FRAME_DURATION);
            }
          }
예제 #16
0
  private void init(Context context) {
    mContext = context;
    loadDefaults();
    initGraphicTools();
    setWillNotDraw(false);

    setFocusable(false);
    setClickable(false);

    mTimerView = new TextView(mContext);
    mTimerView.setId(ViewHelper.generateViewId());
    mTimerView.setTextColor(
        mContext.getResources().getColor(R.color.camera_overlay_timerTextColor));
    mTimerView.setTextSize(
        mContext.getResources().getDimension(R.dimen.camera_overlay_timerTextSize));

    float shadowRadius = mContext.getResources().getDimension(R.dimen.camera_overlay_shadowRadius);
    mTimerView.setShadowLayer(shadowRadius, 0, 0, Color.BLACK);
    LayoutParams timerLParams =
        new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    timerLParams.addRule(CENTER_IN_PARENT, mTimerView.getId());
    addView(mTimerView, timerLParams);

    mCountdownAnimation = AnimationUtils.loadAnimation(mContext, R.anim.shot_countdown_scale_up);
  }
	private void init(Context context) {
		mResistance = DEFAULT_RESISTANCE;

		// Add the list and the header to the container.
		mContainer = new LinearLayout(context);
		mContainer.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		((LinearLayout) mContainer).setOrientation(LinearLayout.VERTICAL);
		addView(mContainer);

		mState = STATE_IDLE; // Start out as idle.

		// We don't want to see the fading edge on the container.
		setVerticalFadingEdgeEnabled(false);
		setVerticalScrollBarEnabled(false);

		// Set the default list and header.
		TextView headerView = new TextView(context);
		headerView.setText("Default refresh header.");
		int headerViewId = 15134;
		headerView.setId(headerViewId);
		LinearLayout headerContainer = new LinearLayout(context);
		headerContainer.setPadding(0, 100, 0, 0);
		headerContainer.addView(headerView);
		setRefreshHeader(headerContainer, headerViewId);
		ListView list = new ListView(context);
		setList(list);
	}
  @Override
  public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    LinearLayout itemView = new LinearLayout(parent.getContext());

    TextView textView = new TextView(parent.getContext());
    textView.setTextSize(18);
    textView.setId(android.R.id.text1);

    RecyclerView.LayoutParams layoutParams =
        new RecyclerView.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, Converter.dp2px(itemView.getContext(), 56));

    itemView.setPadding(
        Converter.dp2px(itemView.getContext(), 16),
        0,
        Converter.dp2px(itemView.getContext(), 16),
        0);
    itemView.setGravity(Gravity.LEFT | Gravity.START | Gravity.CENTER);
    itemView.setBackgroundResource(R.drawable.touch_feedback_holo_light);
    itemView.addView(textView);
    itemView.setLayoutParams(layoutParams);
    if (this.layoutManager instanceof GridLayoutManager) {
      calculateGridItemSize(itemView);
    }

    return new ViewHolder(itemView);
  }
  /** 初始化Column栏目项 */
  private void initTabColumn() {
    mRadioGroup_content.removeAllViews();

    if (mUserChannelList != null) {
      int count = mUserChannelList.size();
      mColumnHorizontalScrollView.setParam(
          getActivity(),
          mScreenWidth,
          mRadioGroup_content,
          mShadeleft,
          mShaderight,
          ll_more_columns,
          rl_column);
      for (int i = 0; i < count; i++) {
        LinearLayout.LayoutParams params =
            new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        params.leftMargin = 5;
        params.rightMargin = 5;
        //			TextView localTextView = (TextView) mInflater.inflate(R.layout.column_radio_item,
        // null);
        TextView columnTextView = new TextView(getActivity());
        columnTextView.setTextAppearance(getActivity(), R.style.top_category_scroll_view_item_text);
        //
        //	localTextView.setBackground(getResources().getDrawable(R.drawable.top_category_scroll_text_view_bg));
        columnTextView.setBackgroundResource(R.drawable.radio_buttong_bg);
        columnTextView.setGravity(Gravity.CENTER);
        columnTextView.setPadding(5, 5, 5, 5);
        columnTextView.setId(i);
        columnTextView.setText(mUserChannelList.get(i).getName());
        columnTextView.setTextColor(
            getResources().getColorStateList(R.color.top_category_scroll_text_color_day));
        if (columnSelectIndex == i) {
          columnTextView.setSelected(true);
        }
        columnTextView.setOnClickListener(
            new View.OnClickListener() {

              @Override
              public void onClick(View v) {
                for (int i = 0; i < mRadioGroup_content.getChildCount(); i++) {
                  View localView = mRadioGroup_content.getChildAt(i);
                  if (localView != v) localView.setSelected(false);
                  else {
                    localView.setSelected(true);
                    mViewPager.setCurrentItem(i);
                  }
                }
                Toast.makeText(
                        getActivity().getApplicationContext(),
                        mUserChannelList.get(v.getId()).getName(),
                        Toast.LENGTH_SHORT)
                    .show();
              }
            });
        mRadioGroup_content.addView(columnTextView, i, params);
      }
    }
  }
 private TextView createTextView(int id, String text) {
   TextView tv = new TextView(this);
   tv.setGravity(Gravity.CENTER);
   tv.setText(text);
   tv.setWidth(dp2px(60));
   tv.setId(id);
   return tv;
 }
예제 #21
0
 private void initName() {
   logoLP = new LayoutParams(getIntScaleX(200), getIntScaleX(200));
   logoLP.addRule(CENTER_IN_PARENT);
   logo = new TextView(mContext);
   logo.setId(ID_LOGO);
   logo.setLayoutParams(logoLP);
   logo.setBackgroundResource(R.drawable.icon);
   this.addView(logo);
 }
  /** Create the view in which the video will be rendered. */
  private void setupView() {
    LinearLayout lLinLayout = new LinearLayout(this);
    lLinLayout.setId(1);
    lLinLayout.setOrientation(LinearLayout.VERTICAL);
    lLinLayout.setGravity(Gravity.CENTER);
    lLinLayout.setBackgroundColor(Color.BLACK);

    LayoutParams lLinLayoutParms =
        new LayoutParams(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lLinLayout.setLayoutParams(lLinLayoutParms);

    this.setContentView(lLinLayout);

    RelativeLayout lRelLayout = new RelativeLayout(this);
    lRelLayout.setId(2);
    lRelLayout.setGravity(Gravity.CENTER);
    lRelLayout.setBackgroundColor(Color.BLACK);
    android.widget.RelativeLayout.LayoutParams lRelLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    lRelLayout.setLayoutParams(lRelLayoutParms);
    lLinLayout.addView(lRelLayout);

    mVideoView = new VideoView(this);
    mVideoView.setId(3);
    android.widget.RelativeLayout.LayoutParams lVidViewLayoutParams =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lVidViewLayoutParams.addRule(RelativeLayout.CENTER_IN_PARENT);
    mVideoView.setLayoutParams(lVidViewLayoutParams);
    lRelLayout.addView(mVideoView);

    mProgressBar = new ProgressBar(this);
    mProgressBar.setIndeterminate(true);
    mProgressBar.setVisibility(View.VISIBLE);
    mProgressBar.setEnabled(true);
    mProgressBar.setId(4);
    android.widget.RelativeLayout.LayoutParams lProgressBarLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressBarLayoutParms.addRule(RelativeLayout.CENTER_IN_PARENT);
    mProgressBar.setLayoutParams(lProgressBarLayoutParms);
    lRelLayout.addView(mProgressBar);

    mProgressMessage = new TextView(this);
    mProgressMessage.setId(5);
    android.widget.RelativeLayout.LayoutParams lProgressMsgLayoutParms =
        new android.widget.RelativeLayout.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    lProgressMsgLayoutParms.addRule(RelativeLayout.CENTER_HORIZONTAL);
    lProgressMsgLayoutParms.addRule(RelativeLayout.BELOW, 4);
    mProgressMessage.setLayoutParams(lProgressMsgLayoutParms);
    mProgressMessage.setTextColor(Color.LTGRAY);
    mProgressMessage.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12);
    mProgressMessage.setText("...");
    lRelLayout.addView(mProgressMessage);
  }
    protected LinearLayout addIncludedView(int includedRootId, int stringResId) {
      LinearLayout container = new LinearLayout(this);
      container.setId(includedRootId);

      TextView textView = new TextView(this);
      container.addView(textView);
      textView.setId(android.R.id.text2);
      textView.setText(stringResId);
      return container;
    }
예제 #24
0
 private void initLogo() {
   nameLP = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
   nameLP.addRule(CENTER_HORIZONTAL);
   nameLP.addRule(BELOW, ID_LOGO);
   name = new TextView(mContext);
   name.setId(ID_NAME);
   name.setLayoutParams(nameLP);
   name.setText("宁宁猫浏览器");
   name.setTextColor(Color.WHITE);
   name.setTextSize(getIntScaleX(20));
   this.addView(name);
 }
예제 #25
0
 private View createSimpleListItem18(Context ctx) {
   TextView view = new TextView(ctx);
   view.setId(android.R.id.text1);
   view.setLayoutParams(
       new AbsListView.LayoutParams(
           AbsListView.LayoutParams.MATCH_PARENT, AbsListView.LayoutParams.WRAP_CONTENT));
   view.setTextAppearance(ctx, android.R.attr.textAppearanceMedium);
   int padding = BDUtils.dip2px(ctx, 16);
   view.setPadding(padding, padding, padding, padding);
   view.setGravity(Gravity.CENTER);
   return view;
 }
  protected TextView message() {
    LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    params.addRule(ALIGN_PARENT_TOP);
    params.addRule(ALIGN_PARENT_LEFT);
    params.bottomMargin = topBottomPaddingOne;

    TextView v = new TextView(getContext());
    v.setId(RandomId.get());
    v.setLayoutParams(params);
    messageTextStyle.style(v);

    return v;
  }
예제 #27
0
  public TriggerWidget(Context context, FormEntryPrompt prompt) {
    super(context, prompt);
    mPrompt = prompt;

    this.setOrientation(LinearLayout.VERTICAL);

    mTriggerButton = new CheckBox(getContext());
    mTriggerButton.setId(QuestionWidget.newUniqueId());
    mTriggerButton.setText(getContext().getString(R.string.trigger));
    mTriggerButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    // mActionButton.setPadding(20, 20, 20, 20);
    mTriggerButton.setEnabled(!prompt.isReadOnly());

    mTriggerButton.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            if (mTriggerButton.isChecked()) {
              mStringAnswer.setText(mOK);
              Collect.getInstance()
                  .getActivityLogger()
                  .logInstanceAction(TriggerWidget.this, "triggerButton", "OK", mPrompt.getIndex());
            } else {
              mStringAnswer.setText(null);
              Collect.getInstance()
                  .getActivityLogger()
                  .logInstanceAction(
                      TriggerWidget.this, "triggerButton", "null", mPrompt.getIndex());
            }
          }
        });

    mStringAnswer = new TextView(getContext());
    mStringAnswer.setId(QuestionWidget.newUniqueId());
    mStringAnswer.setTextSize(TypedValue.COMPLEX_UNIT_DIP, mAnswerFontsize);
    mStringAnswer.setGravity(Gravity.CENTER);

    String s = prompt.getAnswerText();
    if (s != null) {
      if (s.equals(mOK)) {
        mTriggerButton.setChecked(true);
      } else {
        mTriggerButton.setChecked(false);
      }
      mStringAnswer.setText(s);
    }

    // finish complex layout
    this.addView(mTriggerButton);
    // this.addView(mStringAnswer);
  }
  protected TextView unitHeightFillView() {
    LayoutParams params =
        new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(ALIGN_PARENT_RIGHT);

    TextView v = new TextView(getContext());
    v.setId(RandomId.get());
    v.setLayoutParams(params);
    styleNote.style(v);
    v.setText("UNIT");
    v.setVisibility(INVISIBLE);

    return v;
  }
  protected TextView triggerTime(View leftView) {
    LayoutParams params =
        new LayoutParams(LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(RIGHT_OF, leftView.getId());
    params.addRule(CENTER_VERTICAL);
    params.addRule(ALIGN_PARENT_RIGHT);

    TextView v = new TextView(getContext());
    v.setId(RandomId.get());
    v.setLayoutParams(params);
    triggeredTextStyle.style(v);

    return v;
  }
  protected TextView fieldValue(View rightView) {
    LayoutParams params =
        new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    params.addRule(LEFT_OF, rightView.getId());

    TextView v = new TextView(getContext());
    v.setId(RandomId.get());
    v.setLayoutParams(params);
    v.setGravity(Gravity.CENTER_VERTICAL | Gravity.RIGHT);
    styleBodyTwo.style(v);
    v.setText("NUM");

    return v;
  }