Exemplo n.º 1
0
 @Override
 @NonNull
 protected LinearLayout makeCenterView() {
   LinearLayout rootLayout = new LinearLayout(activity);
   rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
   rootLayout.setOrientation(LinearLayout.VERTICAL);
   blackColorView = new ColorPanelView(activity);
   //noinspection ResourceType
   blackColorView.setId(BLACK_ID);
   blackColorView.setLayoutParams(
       new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
   blackColorView.setPointerDrawable(
       CompatUtils.getDrawable(activity, R.drawable.color_picker_cursor_bottom));
   blackColorView.setLockPointerInBounds(false);
   blackColorView.setOnColorChangedListener(
       new ColorPanelView.OnColorChangedListener() {
         @Override
         public void onColorChanged(ColorPanelView view, int color) {
           updateCurrentColor(color);
         }
       });
   rootLayout.addView(blackColorView);
   multiColorView = new ColorPanelView(activity);
   //noinspection ResourceType
   multiColorView.setId(MULTI_ID);
   multiColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
   multiColorView.setPointerDrawable(
       CompatUtils.getDrawable(activity, R.drawable.color_picker_cursor_top));
   multiColorView.setLockPointerInBounds(true);
   multiColorView.setOnColorChangedListener(
       new ColorPanelView.OnColorChangedListener() {
         @Override
         public void onColorChanged(ColorPanelView view, int color) {
           updateCurrentColor(color);
         }
       });
   rootLayout.addView(multiColorView);
   LinearLayout previewLayout = new LinearLayout(activity);
   previewLayout.setOrientation(LinearLayout.HORIZONTAL);
   previewLayout.setGravity(Gravity.CENTER);
   previewLayout.setLayoutParams(
       new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
   hexValView = new EditText(activity);
   hexValView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
   hexValView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
   hexValView.setImeOptions(EditorInfo.IME_ACTION_DONE);
   hexValView.setGravity(Gravity.CENTER);
   hexValView.setBackgroundColor(initColor);
   hexValView.setTextColor(Color.BLACK);
   hexValView.setShadowLayer(3, 0, 2, Color.WHITE); // 设置阴影,以便背景色为黑色系列时仍然看得见
   hexValView.setMinEms(6);
   hexValView.setMaxEms(8);
   hexValView.setPadding(0, 0, 0, 0);
   hexValView.setSingleLine(true);
   hexValView.setOnEditorActionListener(this);
   hexValDefaultColor = hexValView.getTextColors();
   previewLayout.addView(hexValView);
   rootLayout.addView(previewLayout);
   return rootLayout;
 }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle state) {
    super.onCreate(state);

    setRequestedOrientation(SCREEN_ORIENTATION_NOSENSOR);

    String qrData = getIntent().getStringExtra(Intent.EXTRA_TEXT);

    cameraView = new CameraView(this);
    cameraBorder = new LinearLayout(this);
    cameraBorder.setGravity(CENTER);
    cameraBorder.setBackgroundColor(BLACK);
    cameraBorder.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f));
    cameraBorder.addView(cameraView);

    ImageView qrCodeView = new ImageView(this);

    qrCodeView.setScaleType(FIT_CENTER);
    qrCodeView.setBackgroundColor(WHITE);
    qrCodeView.setLayoutParams(new LayoutParams(MATCH_PARENT, WRAP_CONTENT, 1f));

    Display display = getWindowManager().getDefaultDisplay();
    boolean portrait = display.getWidth() < display.getHeight();
    layoutMain = new LinearLayout(this);
    if (portrait) layoutMain.setOrientation(VERTICAL);
    else layoutMain.setOrientation(HORIZONTAL);
    layoutMain.setWeightSum(2);
    layoutMain.addView(cameraBorder);
    layoutMain.addView(qrCodeView);
    setContentView(layoutMain);

    new QrGenAsyncTask(this, qrCodeView).execute(qrData);
  }
Exemplo n.º 3
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    ActionBar actionBar = activity.getActionBar();
    View view = actionBar.getCustomView();
    ImageView title_image = (ImageView) view.findViewById(R.id.title_image);
    title_image.setBackgroundResource(R.drawable.substancea_cs);

    ScrollView sv = new ScrollView(activity);
    sv.setLayoutParams(
        new ViewGroup.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
    sv.setFillViewport(true);

    LinearLayout lay = new LinearLayout(activity);
    lay.setOrientation(LinearLayout.VERTICAL);
    lay.setBackgroundColor(Color.WHITE);
    LinearLayout.LayoutParams params =
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    sv.addView(lay, params);
    // setContentView(sv);

    search_lay.setOnClickListener(searchLis);
    search_btn.setOnClickListener(searchLis);
    showLinelay = new LinearLayout(activity);
    ((LinearLayout) showLinelay).setOrientation(LinearLayout.VERTICAL);
    lay.addView(showLinelay, params);
    initNet();
    loadData(new RequestPram());
  }
Exemplo n.º 4
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    LinearLayout myLayout = new LinearLayout(this);
    myLayout.setOrientation(LinearLayout.VERTICAL);

    input1 = new EditText(this);
    output1 = new TextView(this);

    button1 = new Button(this);

    bannerText = new TextView(this);

    myLayout.setOrientation(LinearLayout.VERTICAL);
    myLayout.setGravity(Gravity.CENTER_HORIZONTAL);
    myLayout.setBackgroundColor(Color.LTGRAY);

    bannerText.setWidth(300);
    bannerText.setGravity(Gravity.CENTER_HORIZONTAL);
    bannerText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 50);
    bannerText.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    bannerText.setText(" Currency Converter from Dollar $ to Birr");
    bannerText.setTextColor(Color.BLUE);
    bannerText.setPadding(0, 0, 0, 10);

    input1.setHint("Enter Dollar amount");
    button1.setText("Convert to Birr!");

    output1.setText("0");
    output1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 30);
    output1.setPadding(0, 20, 0, 20);
    output1.setWidth(150);
    output1.setGravity(Gravity.CENTER_HORIZONTAL);
    output1.setTextColor(Color.WHITE);

    // button1.setOnClickListener(myListener);

    button1.setOnClickListener(this);

    myLayout.addView(bannerText);
    myLayout.addView(input1);
    myLayout.addView(output1);

    myLayout.addView(button1);

    LinearLayout.LayoutParams parm = new RadioGroup.LayoutParams(300, 100);

    input1.setLayoutParams(parm);
    output1.setLayoutParams(parm);
    button1.setLayoutParams(parm);

    setContentView(myLayout);

    input1.setLayoutParams(new LinearLayout.LayoutParams(225, 50));
    button1.setLayoutParams(new LinearLayout.LayoutParams(170, 50));
    // button2.setLayoutParams(new LinearLayout.LayoutParams(170, 50));

  }
Exemplo n.º 5
0
  public void displayToastWithImg(Context context, String str, int resId, int position) {

    Toast toast = Toast.makeText(context, str, Toast.LENGTH_SHORT);
    LinearLayout toastView = (LinearLayout) toast.getView();
    ImageView imageView = new ImageView(context);
    imageView.setImageResource(resId);
    switch (position) {
      case 1:
        toastView.addView(imageView, 0);
        break;
      case 2:
        toastView.addView(imageView, 1);
        break;
      case 3:
        toastView.setOrientation(LinearLayout.HORIZONTAL);
        toastView.addView(imageView, 0);
        break;
      case 4:
        toastView.setOrientation(LinearLayout.HORIZONTAL);
        toastView.addView(imageView, 1);
        break;
      default:
        break;
    }
    toast.show();
  }
Exemplo n.º 6
0
  private void init(MainView v, Object params) {
    Context ctx = RhodesActivity.getContext();

    view = new MyView(ctx);
    view.setOrientation(LinearLayout.VERTICAL);
    view.setGravity(Gravity.BOTTOM);
    view.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, FILL_PARENT));

    webView = null;
    if (v != null) webView = v.detachWebView();
    if (webView == null) webView = RhodesActivity.safeGetInstance().createWebView();
    view.addView(webView, new LinearLayout.LayoutParams(FILL_PARENT, 0, 1));

    LinearLayout bottom = new LinearLayout(ctx);
    bottom.setOrientation(LinearLayout.HORIZONTAL);
    bottom.setBackgroundColor(Color.GRAY);
    bottom.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0));
    view.addView(bottom);

    toolBar = bottom;

    setupToolbar(toolBar, params);

    webView.requestFocus();
  }
  private void buildUi() {
    LinearLayout top = new LinearLayout(this);
    top.setOrientation(LinearLayout.VERTICAL);

    List<ActivityManager.RecentTaskInfo> recents =
        mAm.getRecentTasks(10, ActivityManager.RECENT_WITH_EXCLUDED);
    if (recents != null) {
      for (int i = 0; i < recents.size(); i++) {
        ActivityManager.RecentTaskInfo r = recents.get(i);
        ActivityManager.TaskThumbnail tt = mAm.getTaskThumbnail(r.persistentId);
        TextView tv = new TextView(this);
        tv.setText(r.baseIntent.getComponent().flattenToShortString());
        top.addView(
            tv,
            new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
        LinearLayout item = new LinearLayout(this);
        item.setOrientation(LinearLayout.HORIZONTAL);
        addThumbnail(item, tt != null ? tt.mainThumbnail : null, r, tt);
        top.addView(
            item,
            new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT));
      }
    }

    setContentView(scrollWrap(top));
  }
  private void addUniversalButtonLayoutToDialogView(String name, String signal) {
    TextWatcher tw =
        new TextWatcher() {
          @Override
          public void onTextChanged(CharSequence s, int start, int before, int count) {}

          @Override
          public void beforeTextChanged(CharSequence s, int start, int count, int after) {}

          @Override
          public void afterTextChanged(Editable s) {
            sendChannelDetailsChangedBroadcast(
                getActivity(), null, 0, null, -1, getCurrentUniversalButtons());
          }
        };
    LinearLayout newUniversalButtonLayout = new LinearLayout(getActivity());
    newUniversalButtonLayout.setOrientation(LinearLayout.VERTICAL);

    LinearLayout nameLayout = new LinearLayout(getActivity());
    nameLayout.setOrientation(LinearLayout.HORIZONTAL);

    AppCompatEditText universalButtonNameEditText = new AppCompatEditText(getActivity());
    universalButtonNameEditText.setHint(R.string.name);
    universalButtonNameEditText.setText(name);
    universalButtonNameEditText.addTextChangedListener(tw);

    ImageButton deleteUniversalButton = new ImageButton(getActivity());
    deleteUniversalButton.setBackgroundResource(android.R.color.transparent);
    deleteUniversalButton.setImageResource(android.R.drawable.ic_menu_delete);
    deleteUniversalButton.setOnClickListener(
        new View.OnClickListener() {

          @Override
          public void onClick(View v) {
            buttonsList.removeView((View) v.getParent().getParent());
            sendChannelDetailsChangedBroadcast(
                getActivity(), null, 0, null, -1, getCurrentUniversalButtons());
          }
        });

    nameLayout.addView(
        universalButtonNameEditText,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT, 1.0f));
    nameLayout.addView(deleteUniversalButton);

    AppCompatEditText universalButtonSignalEditText = new AppCompatEditText(getActivity());
    universalButtonSignalEditText.setHint(R.string.enter_network_signal);
    universalButtonSignalEditText.setText(signal);
    universalButtonSignalEditText.addTextChangedListener(tw);

    newUniversalButtonLayout.addView(nameLayout);
    newUniversalButtonLayout.addView(universalButtonSignalEditText);

    buttonsList.addView(newUniversalButtonLayout);
  }
  @Override
  public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);

    // Checks the orientation of the screen
    if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
      masterRow.setOrientation(LinearLayout.HORIZONTAL);
    } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
      masterRow.setOrientation(LinearLayout.VERTICAL);
    }
  }
Exemplo n.º 10
0
  /**
   * getChildView
   *
   * @param int group_position
   * @param int child_position
   * @param boolean is_last_child
   * @param View convert_view
   * @param ViewGroup parent
   * @return View
   */
  public View getChildView(
      int group_position,
      int child_position,
      boolean is_last_child,
      View convert_view,
      ViewGroup parent) {
    // get the current setting
    ServiceSetting setting = (ServiceSetting) getChild(group_position, child_position);

    // create a text layout
    AbsListView.LayoutParams text_layout_params =
        new AbsListView.LayoutParams(
            ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout text_layout = new LinearLayout(activity);
    TextView text_view = getGenericView();

    text_view.setText(setting.getDisplayName());
    text_view.setTextColor(Color.BLACK);
    text_layout.setLayoutParams(text_layout_params);
    text_layout.setOrientation(LinearLayout.HORIZONTAL);
    text_layout.addView(text_view);

    // create checkbox
    CheckBox check_box = new CheckBox(activity);
    check_box.setChecked(setting.getPrefValue());
    check_box.setOnClickListener(setting);

    // create a check box layout
    AbsListView.LayoutParams check_box_layout_params =
        new AbsListView.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    LinearLayout check_box_layout = new LinearLayout(activity);

    check_box_layout.setLayoutParams(check_box_layout_params);
    check_box_layout.setGravity(Gravity.RIGHT);
    check_box_layout.setPadding(0, 0, 5, 0);
    check_box_layout.addView(check_box);

    // create row and add text and check box layouts to it
    AbsListView.LayoutParams main_layout_params =
        new AbsListView.LayoutParams(
            ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    LinearLayout main_layout = new LinearLayout(activity);

    // add to main layout
    main_layout.setLayoutParams(main_layout_params);
    main_layout.setOrientation(LinearLayout.HORIZONTAL);
    main_layout.addView(text_layout);
    main_layout.setGravity(Gravity.CENTER);
    main_layout.addView(check_box_layout);

    return main_layout;
  }
Exemplo n.º 11
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    LinearLayout layoutMain = new LinearLayout(this);
    layoutMain.setOrientation(LinearLayout.VERTICAL);
    layoutMain.setBackgroundColor(Color.CYAN);

    LinearLayout layoutTitle = new LinearLayout(this);
    layoutTitle.setOrientation(LinearLayout.VERTICAL);
    layoutTitle.setGravity(Gravity.TOP);
    layoutMain.addView(layoutTitle);

    TextView heading = new TextView(this);
    heading.setText("DETECTING INPUT EVENTS \n (Click Or Long Press)");
    heading.setHeight(100);
    heading.setGravity(Gravity.TOP | Gravity.CENTER);
    heading.setBackgroundColor(Color.YELLOW);
    heading.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    heading.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    layoutTitle.addView(heading);

    LinearLayout layoutBody = new LinearLayout(this);
    layoutBody.setOrientation(LinearLayout.VERTICAL);
    layoutBody.setGravity(Gravity.CENTER_HORIZONTAL);
    layoutMain.addView(layoutBody);

    Button btn1 = new Button(this);
    btn1.setWidth(10);
    btn1.setGravity(Gravity.CENTER);
    btn1.setTextSize(TypedValue.COMPLEX_UNIT_SP, 25);
    btn1.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    btn1.setText("Click Me With Any Style");
    layoutBody.addView(btn1);

    btn1.setOnClickListener(this);
    btn1.setOnLongClickListener(
        new View.OnLongClickListener() {
          public boolean onLongClick(View v) {
            result.setText("You long pressed the button !!");
            return true;
          }
        });

    result = new TextView(this);
    result.setHeight(200);
    result.setGravity(Gravity.CENTER);
    result.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
    result.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
    layoutBody.addView(result);

    setContentView(layoutMain);
  }
  /** Config UI just one time */
  private void configUI() {
    setOrientation(LinearLayout.VERTICAL);
    setPadding(8, 8, 8, 8);

    TextView titleView = new TextView(ctx);
    titleView.setText(TEXT_TITLE);
    titleView.setTextColor(Color.LTGRAY);
    addView(titleView);

    LinearLayout subLayout = new LinearLayout(ctx);
    subLayout.setOrientation(LinearLayout.HORIZONTAL);
    LinearLayout.LayoutParams subLayoutParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    // configuring the iconView
    iconView.setImageDrawable(icon);
    LayoutParams icParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
    icParams.gravity = Gravity.CENTER_VERTICAL;

    // configuring the msgView
    msgView.setText(msg);
    msgView.setPadding(10, 0, 0, 0);
    msgView.setTextSize(20);
    msgView.setTextColor(Color.WHITE);
    msgView.setGravity(Gravity.CENTER_VERTICAL);
    msgView.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    msgView.setMaxLines(1);
    LayoutParams tvParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);

    subLayout.addView(iconView, icParams);
    subLayout.addView(msgView, tvParams);

    addView(subLayout, subLayoutParams);

    actionBtn.setText(TEXT_DELETE);
    actionBtn.setTextColor(Color.WHITE);
    addView(actionBtn, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));

    undoRedoLayout.setOrientation(LinearLayout.HORIZONTAL);
    undoView = new ImageView(ctx);
    redoView = new ImageView(ctx);
    undoView.setImageDrawable(DrawableFactory.build(ctx, DrawableFactory.ICON_UNDO));
    redoView.setImageDrawable(DrawableFactory.build(ctx, DrawableFactory.ICON_REDO));
    undoView.setClickable(true);
    redoView.setClickable(true);
    LayoutParams undoRedoParams =
        new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    undoRedoParams.weight = 1;
    undoRedoLayout.addView(undoView, undoRedoParams);
    undoRedoLayout.addView(redoView, undoRedoParams);
    addView(undoRedoLayout);
  }
  @Override
  public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    final OsmandApplication app = ((OsmandApplication) getApplication());

    LinearLayout gl = new LinearLayout(this);
    gl.setOrientation(LinearLayout.VERTICAL);
    gl.setPadding(3, 3, 3, 3);

    TextView tv = new TextView(this);
    tv.setText(
        "Press buttons and listen various voice instructions, if you don't hear anything probably they are missed.");
    tv.setPadding(0, 5, 0, 7);

    ScrollView sv = new ScrollView(this);
    gl.addView(
        sv,
        new LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.FILL_PARENT));
    final LinearLayout ll = new LinearLayout(this);
    ll.setOrientation(LinearLayout.VERTICAL);
    sv.addView(
        ll,
        new LayoutParams(
            android.view.ViewGroup.LayoutParams.FILL_PARENT,
            android.view.ViewGroup.LayoutParams.FILL_PARENT));

    // add buttons
    setContentView(gl);
    Runnable r =
        new Runnable() {

          @Override
          public void run() {
            CommandPlayer p = app.getRoutingHelper().getVoiceRouter().getPlayer();
            if (p == null) {
              Toast.makeText(
                      TestVoiceActivity.this, "Voice player not initialized", Toast.LENGTH_SHORT)
                  .show();
            } else {
              addButtons(ll, p);
            }
          }
        };
    if (app.getRoutingHelper().getVoiceRouter().getPlayer() != null) {
      r.run();
    } else {
      app.showDialogInitializingCommandPlayer(this, true, r);
    }
  }
  /** Initialize the Fragment */
  @Override
  public void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);

    if (CPU.isBigLITTLE()) {
      DDividerCard bigDivider = new DDividerCard();
      bigDivider.setText(getString(R.string.big).toLowerCase());
      addView(bigDivider);
    }

    uptimeCard = new CardViewItem.DCardView();
    uptimeCard.setTitle(getString(R.string.uptime));
    addView(uptimeCard);

    additionalCard = new CardViewItem.DCardView();
    additionalCard.setTitle(getString(R.string.unused_cpu_states));
    addView(additionalCard);

    uiStatesView = new LinearLayout(getActivity());
    uiStatesView.setOrientation(LinearLayout.VERTICAL);
    frequencyCard = new CardViewItem.DCardView();
    frequencyCard.setTitle(getString(R.string.frequency_table));
    frequencyCard.setView(uiStatesView);
    frequencyCard.setFullSpan(true);
    addView(frequencyCard);

    if (CPU.isBigLITTLE()) {
      DDividerCard LITTLEDivider = new DDividerCard();
      LITTLEDivider.setText(getString(R.string.little));
      addView(LITTLEDivider);

      uptimeCardLITTLE = new CardViewItem.DCardView();
      uptimeCardLITTLE.setTitle(getString(R.string.uptime));
      addView(uptimeCardLITTLE);

      additionalCardLITTLE = new CardViewItem.DCardView();
      additionalCardLITTLE.setTitle(getString(R.string.unused_cpu_states));
      addView(additionalCardLITTLE);

      uiStatesViewLITTLE = new LinearLayout(getActivity());
      uiStatesViewLITTLE.setOrientation(LinearLayout.VERTICAL);
      frequencyCardLITTLE = new CardViewItem.DCardView();
      frequencyCardLITTLE.setTitle(getString(R.string.frequency_table));
      frequencyCardLITTLE.setView(uiStatesViewLITTLE);
      frequencyCardLITTLE.setFullSpan(true);
      addView(frequencyCardLITTLE);
    }
  }
    // 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);
    }
Exemplo n.º 16
0
  /**
   * add the section tabs for different segment structures. For example in Genesis these can be:
   * Chapters | Parshas | Commentary
   *
   * @param nodeList
   */
  private void addTabsection(List<BilingualNode> nodeList) {
    tabRoot = new LinearLayout(context);
    tabRoot.setOrientation(LinearLayout.HORIZONTAL);
    tabRoot.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    tabRoot.setGravity(Gravity.CENTER);
    this.addView(tabRoot, 0); // make sure it's on top

    for (int count = 0; count < nodeList.size(); count++) {
      MenuNode menuNode = (MenuNode) nodeList.get(count);
      // although generally this isn't necessary b/c the nodes come from menuState.getSections
      // this is used when rebuilding after memory dump and nodes come from setHasTabs()
      if (menuNode.getTitle(Util.Lang.EN).equals("Commentary")
          || (menuNode.getTitle(Util.Lang.EN).equals("Rif"))) {

        continue;
      }
      if (count > 0 && count < nodeList.size()) {
        LayoutInflater inflater =
            (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);

        inflater.inflate(R.layout.tab_divider_menu, tabRoot);
      }

      MenuButtonTab mbt = new MenuButtonTab(context, menuNode, menuState.getLang());
      mbt.setOnClickListener(tabButtonClick);
      tabRoot.addView(mbt);
      menuElementList.add(mbt);
      menuButtonTabList.add(mbt);
    }
  }
Exemplo n.º 17
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    GdxTests.tests.add(MatrixTest.class);

    LinearLayout layout = new LinearLayout(this);
    layout.setOrientation(LinearLayout.HORIZONTAL);

    list = new FrameLayout(this);
    list.setId(1);
    list.setLayoutParams(
        new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
    layout.addView(list);

    list.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 1));

    view = new FrameLayout(this);
    view.setId(2);
    view.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.MATCH_PARENT, 2));
    layout.addView(view);

    setContentView(layout);

    if (savedInstanceState == null) {
      getSupportFragmentManager().beginTransaction().add(1, new TestListFragment()).commit();
    }
  }
Exemplo n.º 18
0
  /**
   * 创建单式机选界面
   *
   * @param number
   * @return
   */
  public View createDanView(int teamNum) {
    touzhuDialog.zhuShu = 0;
    touzhuDialog.setAlertText();
    int checkTeam = teamNum;
    if (teamNum > maxTeam) {
      teamNum = maxTeam;
    }
    int danNum = getNum(teamNum, true);
    int danTeamNum = touzhuDialog.getIsDanNum();
    int isDanNum = getDanNum(danTeamNum, true);
    LinearLayout layoutMain = new LinearLayout(context);
    layoutMain.setOrientation(LinearLayout.VERTICAL);
    if (danNum > LineNum) {
      int num = danNum % LineNum;
      int line = danNum / LineNum;
      for (int i = 0; i < line; i++) {
        addLine(layoutMain, i, LineNum, isDanNum, danTeamNum, checkTeam, false);
      }
      if (num != 0) {
        addLine(layoutMain, line, num, isDanNum, danTeamNum, checkTeam, false);
      }
    } else {
      LinearLayout layoutOne = new LinearLayout(context);
      addLine(layoutMain, 0, danNum, isDanNum, danTeamNum, checkTeam, false);
    }

    return layoutMain;
  }
Exemplo n.º 19
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mSpinner = new ProgressDialog(getContext());

    mSpinner.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mSpinner.setMessage("Loading...");

    mContent = new LinearLayout(getContext());

    mContent.setOrientation(LinearLayout.VERTICAL);

    setUpTitle();
    setUpWebView();

    Display display = getWindow().getWindowManager().getDefaultDisplay();
    final float scale = getContext().getResources().getDisplayMetrics().density;
    float[] dimensions =
        (display.getWidth() < display.getHeight()) ? DIMENSIONS_PORTRAIT : DIMENSIONS_LANDSCAPE;

    addContentView(
        mContent,
        new FrameLayout.LayoutParams(
            (int) (dimensions[0] * scale + 0.5f), (int) (dimensions[1] * scale + 0.5f)));
  }
Exemplo n.º 20
0
  @Override
  protected View onCreateDialogView() {
    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    mValueText = new TextView(mContext);
    mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueText.setTextSize(32);
    params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mValueText, params);

    mSeekBar = new SeekBar(mContext);
    mSeekBar.setOnSeekBarChangeListener(this);

    layout.addView(
        mSeekBar,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist()) {
      mValue = getPersistedInt(mDefault);
    }

    mSeekBar.setMax((int) ((mMax - mMin) / mInterval));
    mSeekBar.setProgress((int) ((mValue - mMin) / mInterval));

    String t = String.valueOf(mValue);
    mValueText.setText(mSuffix == null ? t : t.concat(mSuffix));
    return layout;
  }
Exemplo n.º 21
0
    private LinearLayout getView(int position, Context context) {
      LinearLayout ll = new LinearLayout(context);
      ll.setOrientation(LinearLayout.VERTICAL);
      int dp_5 = cn.sharesdk.framework.utils.R.dipToPx(context, 5);
      ll.setPadding(dp_5, dp_5, dp_5, dp_5);

      ImageView iv = new ImageView(context);
      iv.setScaleType(ScaleType.CENTER_INSIDE);
      LinearLayout.LayoutParams lpIv = new LinearLayout.LayoutParams(iconWidth, iconWidth);
      lpIv.gravity = Gravity.CENTER_HORIZONTAL;
      iv.setLayoutParams(lpIv);
      iv.setImageBitmap(getIcon(platforms[position]));
      ll.addView(iv);

      TextView tv = new TextView(context);
      tv.setTextColor(0xffffffff);
      tv.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
      tv.setSingleLine();
      tv.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.TOP);
      LinearLayout.LayoutParams lpTv =
          new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT);
      lpTv.weight = 1;
      tv.setLayoutParams(lpTv);
      tv.setText(getName(platforms[position]));
      ll.addView(tv);

      return ll;
    }
  public void doThis(final Button button) {
    AlertDialog.Builder alert = new AlertDialog.Builder(this);
    alert.setTitle("What do you want to do?");
    LinearLayout llAlert = new LinearLayout(this);
    llAlert.setOrientation(1);
    alert.setView(llAlert);

    alert.setPositiveButton(
        "Edit",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            edit(button);
          }
        });

    alert.setNegativeButton(
        "Delete",
        new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            delete(button);
          }
        });

    alert.show();
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.tuangouhui_fregment, container, false);
    list = (ListView) view.findViewById(R.id.list);
    inflater = getActivity().getLayoutInflater();
    LinearLayout layout = new LinearLayout(getActivity());
    layout.setOrientation(LinearLayout.VERTICAL);
    View headerView = inflater.inflate(R.layout.list_header, layout);
    initheaderview(headerView);
    mActor.initTGHView(list, headerView);
    tittle = (TextView) view.findViewById(R.id.tv_header_tittle);
    tittle.setText("线下活动");
    btn_right = (Button) view.findViewById(R.id.setting);
    btn_right.setBackgroundResource(R.drawable.bg_search_left);

    list.setOnScrollListener(
        new OnScrollListener() {

          @Override
          public void onScrollStateChanged(AbsListView arg0, int arg1) {}

          @Override
          public void onScroll(AbsListView arg0, int arg1, int arg2, int arg3) {}
        });
    return view;
  }
Exemplo n.º 24
0
 public CustomDialog(Context context) {
   super(context);
   items = new ArrayList<>();
   icon = getContext().getResources().getDimensionPixelSize(R.dimen.dimen_32_dp);
   padding = getContext().getResources().getDimensionPixelSize(R.dimen.dimen_8_dp);
   ViewGroup.LayoutParams params =
       new ViewGroup.LayoutParams(
           ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
   container = new LinearLayout(getContext());
   container.setLayoutParams(params);
   container.setBackgroundColor(Color.WHITE);
   container.setOrientation(LinearLayout.VERTICAL);
   container.setPadding(0, padding, 0, padding);
   ScrollView scrollView = new ScrollView(getContext());
   scrollView.addView(container);
   requestWindowFeature(Window.FEATURE_NO_TITLE);
   setContentView(scrollView, params);
   setCancelable(true);
   setCanceledOnTouchOutside(true);
   getWindow().setGravity(Gravity.BOTTOM);
   getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
   getWindow()
       .setLayout(
           WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
   getWindow().getAttributes().windowAnimations = R.style.DialogAnimation;
 }
Exemplo n.º 25
0
  @SuppressWarnings("deprecation")
  protected void createViews() {
    // This builds the view.  We could probably get away with NOT having a LinearLayout, but I like
    // having a bucket!
    // This builds the view.  We could probably get away with NOT having a LinearLayout, but I like
    // having a bucket!
    Display display = getWindowManager().getDefaultDisplay();
    int width = display.getWidth();
    int height = display.getHeight();

    root = new LinearLayoutSoftKeyboardDetect(this, width, height);
    root.setOrientation(LinearLayout.VERTICAL);
    root.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 0.0F));

    appView.setId(100);
    appView.setLayoutParams(
        new LinearLayout.LayoutParams(
            ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, 1.0F));

    // Add web view but make it invisible while loading URL
    appView.setVisibility(View.INVISIBLE);
    root.addView((View) appView);
    setContentView(root);

    // TODO: Setting this on the appView causes it to show when <html style="opacity:0">.
    int backgroundColor = preferences.getInteger("BackgroundColor", Color.BLACK);
    root.setBackgroundColor(backgroundColor);
  }
Exemplo n.º 26
0
  @Override
  protected View onCreateDialogView() {
    LinearLayout.LayoutParams params;
    LinearLayout layout = new LinearLayout(mContext);
    layout.setOrientation(LinearLayout.VERTICAL);
    layout.setPadding(6, 6, 6, 6);

    final TextView splashText = new TextView(mContext);
    if (mDialogMessage != null) splashText.setText(mDialogMessage);
    layout.addView(splashText);

    mValueText = new TextView(mContext);
    mValueText.setGravity(Gravity.CENTER_HORIZONTAL);
    mValueText.setTextSize(32);
    params =
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
    layout.addView(mValueText, params);

    mSeekBar = new SeekBar(mContext);
    mSeekBar.setOnSeekBarChangeListener(this);
    layout.addView(
        mSeekBar,
        new LinearLayout.LayoutParams(
            LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));

    if (shouldPersist()) mValue = getPersistedInt(mDefault);

    mSeekBar.setMax(mMax);
    mSeekBar.setProgress(mValue);
    return layout;
  }
Exemplo n.º 27
0
 private View createView() {
   ArrayList<String> addrs = getNetworkAddresses();
   ScrollView parent = new ScrollView(this);
   int fill = LinearLayout.LayoutParams.FILL_PARENT;
   int wrap = LinearLayout.LayoutParams.WRAP_CONTENT;
   LinearLayout.LayoutParams fillAll = new LinearLayout.LayoutParams(fill, fill);
   parent.setLayoutParams(fillAll);
   layout = new LinearLayout(this);
   layout.setOrientation(LinearLayout.VERTICAL);
   layout.setLayoutParams(new LinearLayout.LayoutParams(fill, wrap));
   parent.addView(layout);
   text(R.string.desc_setup_wifi, 20);
   text(R.string.desc_goto_settings);
   text(R.string.desc_enable_kbd);
   text(R.string.desc_toch_input_field);
   text(R.string.desc_change_input_method);
   text("", 15);
   if (addrs.size() == 0) {
     text("Enable wifi or GPRS/3G", 20);
   } else if (addrs.size() == 1) {
     text(getString(R.string.desc_connect_to_one, addrs.get(0), port), 20);
   } else {
     text(R.string.desc_connect_to_any);
     for (String addr : addrs) {
       text("http://" + addr + ":" + port, 20);
     }
   }
   text(R.string.desc_warn);
   text("", 15);
   text(R.string.desc_alt_usb_cable, 20);
   text(R.string.desc_adb_from_sdk);
   text(getString(R.string.desc_cmdline, port, port), 15);
   text(getString(R.string.desc_connect_local, port), 15);
   return parent;
 }
Exemplo n.º 28
0
 public ConcertItem(Context context, Concert concert) {
   super(context);
   this.setOrientation(HORIZONTAL);
   LinearLayout layoutConcertData = new LinearLayout(context);
   layoutConcertData.setOrientation(VERTICAL);
   ImageView imgView = new ImageView(context);
   // LayoutParams llp = new LayoutParams(140, 140, Gravity.CENTER_HORIZONTAL);
   // imgView.setLayoutParams(llp);
   imgView.setBackgroundResource(R.drawable.party1);
   this.addView(imgView);
   TextView title = new TextView(context);
   title.setText(concert.getTitle());
   TextView begin = new TextView(context);
   // begin.setText(concert.getBeginDate());
   TextView end = new TextView(context);
   // end.setText(concert.getEndDate());
   TextView price = new TextView(context);
   price.setText("Price : " + concert.getPrice());
   TextView location = new TextView(context);
   location.setText("Location : " + concert.getLocation());
   layoutConcertData.addView(title);
   // this.layoutConcertData.addView(begin);
   // this.layoutConcertData.addView(end);
   layoutConcertData.addView(price);
   layoutConcertData.addView(location);
   this.addView(imgView);
   this.addView(layoutConcertData);
 }
Exemplo n.º 29
0
  public View createBeijingDanView(int teamNum) {
    int checkTeam = teamNum;
    if (teamNum > beijingChuanMaxTeam) {
      teamNum = beijingChuanMaxTeam;
    }
    int danNum = getBeijingCheckNum(teamNum);

    LinearLayout layoutMain = new LinearLayout(context);
    layoutMain.setOrientation(LinearLayout.VERTICAL);
    if (danNum > LineNum) {
      int num = danNum % LineNum;
      int line = danNum / LineNum;
      for (int i = 0; i < line; i++) {
        addLine(layoutMain, i, LineNum, 0, 0, teamNum, true);
      }
      if (num != 0) {
        addLine(layoutMain, line, num, 0, 0, teamNum, true);
      }
    } else {
      LinearLayout layoutOne = new LinearLayout(context);
      addLine(layoutMain, 0, danNum, 0, 0, teamNum, true);
    }

    return layoutMain;
  }
Exemplo n.º 30
0
  public void addNavBar(String title, Map<Object, Object> left, Map<Object, Object> right) {
    removeNavBar();

    Context ctx = RhodesActivity.getContext();

    LinearLayout top = new LinearLayout(ctx);
    top.setOrientation(LinearLayout.HORIZONTAL);
    top.setBackgroundColor(Color.GRAY);
    top.setGravity(Gravity.CENTER);
    top.setLayoutParams(new LinearLayout.LayoutParams(FILL_PARENT, WRAP_CONTENT, 0));

    View leftButton = createButton(left);
    leftButton.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1));
    top.addView(leftButton);

    TextView label = new TextView(ctx);
    label.setText(title);
    label.setGravity(Gravity.CENTER);
    label.setTextSize((float) 30.0);
    label.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 2));
    top.addView(label);

    if (right != null) {
      View rightButton = createButton(right);
      rightButton.setLayoutParams(new LinearLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT, 1));
      top.addView(rightButton);
    }

    navBar = top;
    view.addView(navBar, 0);
  }