android.widget.TableLayout Java Examples

The following examples show how to use android.widget.TableLayout. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PageHandler.java    From SI with BSD 2-Clause "Simplified" License 6 votes vote down vote up
protected void appendRow( String value ){

        // create table row
        TableLayout tb = (TableLayout)findViewById(R.id.control_table_layout);
        TableRow tableRow = new TableRow(this);
        tableRow.setLayoutParams(tableLayout);

        // get current time
        long time = System.currentTimeMillis();
        SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
        String cur_time = dayTime.format(new Date(time));

        // set Text on TextView
        TextView tv_left = new TextView(this);
        tv_left.setText( cur_time );
        tv_left.setLayoutParams( tableRowLayout );
        tableRow.addView( tv_left );

        TextView tv_right = new TextView(this);
        tv_right.setText( value );
        tv_right.setLayoutParams( tableRowLayout );
        tableRow.addView( tv_right );

        // set table rows on table
        tb.addView(tableRow);
    }
 
Example #2
Source File: ListItemExtensions.java    From Android-WYSIWYG-Editor with Apache License 2.0 6 votes vote down vote up
public void convertListToNormalText(TableLayout _table, int startIndex) {
    int tableChildCount = _table.getChildCount();
    for (int i = startIndex; i < tableChildCount; i++) {
        View _childRow = _table.getChildAt(i);
        _table.removeView(_childRow);
        String text = getTextFromListItem(_childRow);
        int Index = editorCore.getParentView().indexOfChild(_table);
        componentsWrapper.getInputExtensions().insertEditText(Index + 1, "", text);
        i -= 1;
        tableChildCount -= 1;
    }
    //if item is the last in the table, remove the table from parent

    if (_table.getChildCount() == 0) {
        editorCore.getParentView().removeView(_table);
    }
}
 
Example #3
Source File: PebbleConnect.java    From httpebble-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    Settings.upgradeVersion(this);

    ((TextView) findViewById(R.id.notifications)).setMovementMethod(LinkMovementMethod.getInstance());
    ((TextView) findViewById(R.id.source)).setMovementMethod(LinkMovementMethod.getInstance());
    mSetup = (Button) findViewById(R.id.setup);
    mCredentials = (TableLayout) findViewById(R.id.credentials);
    mUsername = (TextView) findViewById(R.id.username);
    mToken = (TextView) findViewById(R.id.token);
    mReset = (Button) findViewById(R.id.reset);
    mDocumentation = (Button) findViewById(R.id.documentation);

    if (!TextUtils.isEmpty(Settings.getEmail(this))) {
        showCredentials();
    }
}
 
Example #4
Source File: TableEntry.java    From Markwon with Apache License 2.0 6 votes vote down vote up
@NonNull
private TableRow ensureRow(@NonNull TableLayout layout, int row) {

    final int count = layout.getChildCount();

    // fill the requested views until we have added the `row` one
    if (row >= count) {

        final Context context = layout.getContext();

        int diff = row - count + 1;
        while (diff > 0) {
            layout.addView(new TableRow(context));
            diff -= 1;
        }
    }

    // return requested child (here it always should be the last one)
    return (TableRow) layout.getChildAt(row);
}
 
Example #5
Source File: RecipeActivity.java    From search-samples with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity)getActivity()).recipe;

    TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null);
        ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #6
Source File: ListItemExtensions.java    From Android-WYSIWYG-Editor with Apache License 2.0 6 votes vote down vote up
@Override
public Node getContent(View view) {
    Node node = getNodeInstance(view);
    node.childs = new ArrayList<>();
    TableLayout table = (TableLayout) view;
    int _rowCount = table.getChildCount();
    for (int j = 0; j < _rowCount; j++) {
        View row = table.getChildAt(j);
        Node node1 = getNodeInstance(row);
        EditText li = row.findViewById(R.id.txtText);
        EditorControl liTag = (EditorControl) li.getTag();
        node1.contentStyles = liTag.editorTextStyles;
        node1.content.add(Html.toHtml(li.getText()));
        node1.textSettings = liTag.textSettings;
        node1.content.add(Html.toHtml(li.getText()));
        node.childs.add(node1);
    }
    return node;
}
 
Example #7
Source File: CustomTableRow.java    From MessagingAndroidChat with MIT License 6 votes vote down vote up
public CustomTableRow(Context context, TableLayout container, int type,String content) {
	super(context);

	this.content = content;
	this.container = container;
	this.context = context;

	switch (type) {
           case Config.CHANNEL_NAME:
               setChannelName();
               break;

           case Config.CHANNEL_ADD:
               setChannelAdd();
               break;

           case Config.CHANNEL_DEL:
               setChannelDel();
               break;
           default:
               break;
       }
}
 
Example #8
Source File: RecipeActivity.java    From search-samples with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity) getActivity()).mRecipe;

    TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
        ((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
                .getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #9
Source File: GameSelector.java    From Simple-Solitaire with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Starts the clicked game. This uses the total index position of the clicked view to get the
 * game.
 *
 * @param view The clicked view.
 */
private void startGame(View view) {
    TableRow row = (TableRow) view.getParent();
    TableLayout table = (TableLayout) row.getParent();
    ArrayList<Integer> orderedList = lg.getOrderedGameList();
    int index = indexes.get(table.indexOfChild(row) * menuColumns + row.indexOfChild(view));
    index = orderedList.indexOf(index);

    //avoid loading two games at once when pressing two buttons at once
    if (prefs.getSavedCurrentGame() != DEFAULT_CURRENT_GAME) {
        return;
    }

    prefs.saveCurrentGame(index);
    Intent intent = new Intent(getApplicationContext(), GameManager.class);
    intent.putExtra(GAME, index);
    startActivityForResult(intent, 0);
}
 
Example #10
Source File: RecipeActivity.java    From app-indexing with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity) getActivity()).mRecipe;

    TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
        ((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
                .getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #11
Source File: CharadesResultsAdapter.java    From gdk-charades-sample with Apache License 2.0 6 votes vote down vote up
/**
 * Inflates and returns a tabular layout that can hold five phrases.
 * <p>
 * This method only inflates the views and sets the tag of the root view to be an array of
 * {@link PhraseViewHolder} objects. The caller should pass this view, or a recycled view if
 * it has one, to {@link #updatePhraseListView(View,int)} in order to populate it with data.
 */
private View inflatePhraseListView(ViewGroup parent) {
    TableLayout table =
            (TableLayout) mLayoutInflater.inflate(R.layout.card_results_phrase_list, parent);

    // Add five phrases to the card, or fewer if it is the last card and the total number of
    // phrases is not an even multiple of PHRASES_PER_CARD.
    PhraseViewHolder[] holders = new PhraseViewHolder[PHRASES_PER_CARD];
    for (int i = 0; i < PHRASES_PER_CARD; i++) {
        TableRow row = (TableRow) mLayoutInflater.inflate(R.layout.table_row_result, null);
        table.addView(row);

        PhraseViewHolder holder = new PhraseViewHolder();
        holder.imageView = (ImageView) row.findViewById(R.id.image);
        holder.phraseView = (TextView) row.findViewById(R.id.phrase);
        holders[i] = holder;
    }
    table.setTag(holders);
    return table;
}
 
Example #12
Source File: TableLayout8.java    From codeexamples-android with Eclipse Public License 1.0 6 votes vote down vote up
private void appendRow(TableLayout table) {
    TableRow row = new TableRow(this);

    TextView label = new TextView(this);
    label.setText(R.string.table_layout_8_quit);
    label.setPadding(3, 3, 3, 3);

    TextView shortcut = new TextView(this);
    shortcut.setText(R.string.table_layout_8_ctrlq);
    shortcut.setPadding(3, 3, 3, 3);
    shortcut.setGravity(Gravity.RIGHT | Gravity.TOP);

    row.addView(label, new TableRow.LayoutParams(1));
    row.addView(shortcut, new TableRow.LayoutParams());

    table.addView(row, new TableLayout.LayoutParams());
}
 
Example #13
Source File: RecipeActivity.java    From io2015-codelabs with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity)getActivity()).recipe;

    TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null);
        ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #14
Source File: RecipeActivity.java    From app-indexing with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity) getActivity()).mRecipe;

    TableLayout table = (TableLayout) rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow) inflater.inflate(R.layout.ingredients_row, null);
        ((TextView) row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView) row.findViewById(R.id.attrib_value)).setText(ingredient
                .getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #15
Source File: TabHandler.java    From ssj with GNU General Public License v3.0 6 votes vote down vote up
private void checkVisualFeedbackTabs()
{
	List<Component> visualFeedbacks = PipelineBuilder.getInstance().getComponentsOfClass(PipelineBuilder.Type.EventHandler, VisualFeedback.class);
	removeComponentsOfClass(additionalTabs, VisualFeedback.class);
	if (!visualFeedbacks.isEmpty())
	{
		boolean anyUnmanaged = false;
		TableLayout visualFeedbackLayout = getTableLayoutForVisualFeedback(visualFeedbacks);
		TabHost.TabSpec newTabSpec = getNewTabSpec(visualFeedbackLayout, visualFeedbacks.get(0).getComponentName(), android.R.drawable.ic_menu_compass); // TODO: Change icon.
		for (Component visualFeedback : visualFeedbacks)
		{
			boolean isManaged = PipelineBuilder.getInstance().isManagedFeedback(visualFeedback);

			if(! isManaged)
			{
				anyUnmanaged = true;
				((VisualFeedback) visualFeedback).options.layout.set(visualFeedbackLayout);
			}
		}
		if(anyUnmanaged)
			additionalTabs.put(visualFeedbacks.get(0), newTabSpec);
	}
}
 
Example #16
Source File: RecipeActivity.java    From search-samples with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.ingredients_fragment, container, false);

    this.recipe = ((RecipeActivity)getActivity()).recipe;

    TableLayout table = (TableLayout)rootView.findViewById(R.id.ingredientsTable);
    for (Recipe.Ingredient ingredient : recipe.getIngredients()) {
        TableRow row = (TableRow)inflater.inflate(R.layout.ingredients_row, null);
        ((TextView)row.findViewById(R.id.attrib_name)).setText(ingredient.getAmount());
        ((TextView)row.findViewById(R.id.attrib_value)).setText(ingredient.getDescription());
        table.addView(row);
    }

    return rootView;
}
 
Example #17
Source File: FilterConfig.java    From personaldnsfilter with GNU General Public License v2.0 6 votes vote down vote up
public FilterConfig(TableLayout table, Button categoryUp, Button categoryDn, TextView categoryField ) {

		configTable = table;
		editDialog = new Dialog(table.getContext(), R.style.Theme_dialog_TitleBar);

		editDialog.setOnKeyListener(this);
		editDialog.setContentView(R.layout.filterentryeditdialog);
		editDialog.setTitle(table.getContext().getResources().getString(R.string.editFilterDialogTitle));
		editOk = editDialog.findViewById(R.id.filterEditOkBtn);
		editDelete = editDialog.findViewById(R.id.filterEditDelBtn);
		editCancel = editDialog.findViewById(R.id.filterEditCancelBtn);
		editOk.setOnClickListener(this);
		editDelete.setOnClickListener(this);
		editCancel.setOnClickListener(this);
		
		this.categoryUp = categoryUp;
		this.categoryDown = categoryDn;
		this.categoryField = categoryField;
		categoryField.setText(ALL_ACTIVE);

		categoryMap = new TreeMap();
	}
 
Example #18
Source File: MessageHolder.java    From zulip-android with Apache License 2.0 6 votes vote down vote up
public MessageHolder(final View itemView) {
    super(itemView);
    gravatar = (ImageView) itemView.findViewById(R.id.gravatar);
    senderName = (TextView) itemView.findViewById(R.id.senderName);
    timestamp = (TextView) itemView.findViewById(R.id.timestamp);
    leftTimestamp = (TextView) itemView.findViewById(R.id.left_timestamp);
    edited = (TextView) itemView.findViewById(R.id.message_edit_tag);
    leftEdited = (TextView) itemView.findViewById(R.id.left_message_edit_tag);
    contentView = (TextView) itemView.findViewById(R.id.contentView);
    contentView.setMovementMethod(LinkMovementMethod.getInstance());
    leftBar = itemView.findViewById(R.id.leftBar);
    messageTile = (RelativeLayout) itemView.findViewById(R.id.messageTile);
    contentImage = (ImageView) itemView.findViewById(R.id.load_image);
    starImage = (ImageView) itemView.findViewById(R.id.star_image);
    leftStarImage = (ImageView) itemView.findViewById(R.id.left_star_image);
    contentImageContainer = itemView.findViewById(R.id.load_image_container);
    reactionsTable = (TableLayout) itemView.findViewById(R.id.reactions_table);
    contentView.setOnClickListener(this);
    contentView.setLongClickable(true);
    itemView.setOnCreateContextMenuListener(this);

    // Add click listener to sender view
    View senderView = itemView.findViewById(R.id.senderTile);
    if (senderView != null) senderView.setOnClickListener(this);
}
 
Example #19
Source File: PulldownViewActivity.java    From BigApp_Discuz_Android with Apache License 2.0 5 votes vote down vote up
protected void initView() {
    mScrollView = (PullScrollView) findViewById(R.id.scroll_view);
    mHeadImg = (ImageView) findViewById(R.id.background_img);

    mMainLayout = (TableLayout) findViewById(R.id.table_layout);

    mScrollView.setHeader(mHeadImg);
    mScrollView.setOnTurnListener(this);
}
 
Example #20
Source File: PostContentView.java    From chaoli-forum-for-android-2 with GNU General Public License v3.0 5 votes vote down vote up
private View getHorizontalDivider() {
    View horizontalDivider = new View(mContext);
    horizontalDivider.setLayoutParams(new TableLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 1));
    horizontalDivider.setBackgroundColor(ContextCompat.getColor(mContext, android.R.color.black));

    return horizontalDivider;
}
 
Example #21
Source File: EditCredentialsActivity.java    From WiFiAfterConnect with Apache License 2.0 5 votes vote down vote up
private void addField (HtmlInput field) {
Log.d(Constants.TAG, "adding ["+field.getName() + "], type = [" + field.getType()+"]");

  	TextView labelView =  new TextView(this);
  	labelView.setText(field.getName());
  	int textSize = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_SP, (float) 8, getResources().getDisplayMetrics());
  	labelView.setTextSize (textSize);
  	
  	EditText editView = new EditText(this);
  	editView.setInputType(field.getAndroidInputType());
  	editView.setText (field.getValue());
  	editView.setTag(field.getName());
  	editView.setFocusable (true);
  	
  	edits.add(editView);
  	
  	editView.setOnEditorActionListener(new EditText.OnEditorActionListener() {
	@Override
	public boolean onEditorAction(TextView v, int actionId,	KeyEvent event) {
  			if (actionId == EditorInfo.IME_ACTION_DONE) {
  				onSaveClick(v);
  			}
  			return false;
	}

  	});    	
  	
  	TableRow row = new TableRow (this);
	fieldsTable.addView (row, new TableLayout.LayoutParams(TableLayout.LayoutParams.MATCH_PARENT,TableLayout.LayoutParams.WRAP_CONTENT));

  	TableRow.LayoutParams labelLayout = new TableRow.LayoutParams(TableRow.LayoutParams.WRAP_CONTENT,TableRow.LayoutParams.WRAP_CONTENT);
  	int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, (float) 5, getResources().getDisplayMetrics());
  	labelLayout.setMargins(margin, margin, margin, margin);
  	row.addView(labelView, labelLayout);
  	TableRow.LayoutParams editLayout = new TableRow.LayoutParams(TableRow.LayoutParams.MATCH_PARENT,TableRow.LayoutParams.WRAP_CONTENT);
  	row.addView(editView, editLayout);
  }
 
Example #22
Source File: DisplayModelActivity.java    From nosey with Apache License 2.0 5 votes vote down vote up
public void addModelFieldHeaders(TableLayout table, Inspector.ModelMapInspector inspector) {
    // Get Fields for a given model
    model.getDeclaredFields();
    Field[] allFields = model.getDeclaredFields();
    Arrays.sort(allFields, new MemberComparator<Field>());

    // Add the field headers to the table row
    TableRow headers = new ColoredTableRow(this, RowColors.getColor(table.getChildCount()));
    for (Field field : allFields) {
        if (!Modifier.isStatic(field.getModifiers())) {
            headers.addView(new CellTextView(this, field.getName(), padding, textSize));
        }
    }
    table.addView(headers);
}
 
Example #23
Source File: ScoresActivity.java    From tedroid with Apache License 2.0 5 votes vote down vote up
/** Ecuentra las vistas. */
private void findViews() {
    classicGameHeaderText = (TextView) findViewById(R.id.classic_game_header_text);
    specialGameHeaderText = (TextView) findViewById(R.id.special_game_header_text);
    scoreClassicTable = (TableLayout) findViewById(R.id.score_classic_table);
    scoreSpecialTable = (TableLayout) findViewById(R.id.score_special_table);
}
 
Example #24
Source File: NotificationActivity.java    From MessagingAndroidChat with MIT License 5 votes vote down vote up
private void refreshUI(String message){
    String[] parts = message.split(":");
    Message newMsg = new Message(parts[0], parts[1], new Date().toString());

    TableLayout tableMessages = (TableLayout) findViewById(R.id.tableMessages);

    if (newMsg.user.equals(PreferencesManager.getInstance(NotificationActivity.this).loadUser())) {
        new MessageTableRow(NotificationActivity.this, tableMessages, true, newMsg);
    } else {
        new MessageTableRow(NotificationActivity.this, tableMessages, false, newMsg);
    }
}
 
Example #25
Source File: PulldownViewActivity.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
protected void initView() {
    mScrollView = (PullScrollView) findViewById(R.id.scroll_view);
    mHeadImg = (ImageView) findViewById(R.id.background_img);

    mMainLayout = (TableLayout) findViewById(R.id.table_layout);

    mScrollView.setHeader(mHeadImg);
    mScrollView.setOnTurnListener(this);
}
 
Example #26
Source File: template_automatic_ll.java    From KickAssSlidingMenu with Apache License 2.0 5 votes vote down vote up
protected void tabletTilePortrait() {
    int sizeNow, index = 0, halfSizeOnHold = 0;
    boolean cell_open = false;
    Iterator<bind> loop = list_configuration.iterator();
    TableRow temp_row = newTempHolder();
    while (loop.hasNext()) {
        bind dlp = loop.next();
        sizeNow = dlp.size;
        if (sizeNow == bind.FULL) {
            if (cell_open) {
                //close half
                temp_row = newTempHolderBy2();
                ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, calculateRowHeightBy2()));
                cell_open = false;
                halfSizeOnHold = 0;
            }
            ll.addView(newRelativeLayout(dlp, sizeNow));
        } else if (sizeNow == bind.HALF) {
            if (!cell_open) {
                temp_row = newTempHolder();
                cell_open = true;
            }
            halfSizeOnHold++;
            //adding view to layout
            temp_row.addView(newRelativeLayout(dlp, sizeNow));
        }

        if (index == list_configuration.size() - 1 && cell_open || cell_open && halfSizeOnHold >= 3) {
            ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, row_height));
            cell_open = false;
            halfSizeOnHold = 0;
        }

        index++;
    }
}
 
Example #27
Source File: template_automatic_ll.java    From KickAssSlidingMenu with Apache License 2.0 5 votes vote down vote up
@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    mProgress = (ProgressBar) view.findViewById(R.id.lylib_ui_loading_circle);
    ll = (TableLayout) view.findViewById(R.id.lylib_list_uv);
    measureScreen();
    row_height = calculateRowHeight();
    onLoadData(savedInstanceState);
}
 
Example #28
Source File: ListItemExtensions.java    From Android-WYSIWYG-Editor with Apache License 2.0 5 votes vote down vote up
public TableLayout insertList(int Index, boolean isOrdered, String text) {

        TableLayout table = createTable();
        editorCore.getParentView().addView(table, Index);
        table.setTag(editorCore.createTag(isOrdered ? EditorType.ol : EditorType.ul));
        addListItem(table, isOrdered, text);
        return table;
    }
 
Example #29
Source File: BodyElementTable.java    From RedReader with GNU General Public License v3.0 5 votes vote down vote up
@Override
public View generateView(
		@NonNull final AppCompatActivity activity,
		@Nullable final Integer textColor,
		@Nullable final Float textSize,
		final boolean showLinkButtons) {

	final TableLayout table = new TableLayout(activity);

	for(final BodyElement element : mElements) {

		final View view = element.generateView(activity, textColor, textSize, showLinkButtons);
		table.addView(view);
	}

	table.setShowDividers(LinearLayout.SHOW_DIVIDER_MIDDLE);
	table.setDividerDrawable(new ColorDrawable(Color.GRAY));

	table.setLayoutParams(new ViewGroup.LayoutParams(
			ViewGroup.LayoutParams.WRAP_CONTENT,
			ViewGroup.LayoutParams.WRAP_CONTENT));

	final HorizontalScrollView scrollView = new HorizontalScrollView(activity);

	scrollView.addView(table);

	return scrollView;
}
 
Example #30
Source File: template_automatic_ll.java    From KickAssSlidingMenu with Apache License 2.0 5 votes vote down vote up
protected void tabletTilePortrait() {
    int sizeNow, index = 0, halfSizeOnHold = 0;
    boolean cell_open = false;
    Iterator<bind> loop = list_configuration.iterator();
    TableRow temp_row = newTempHolder();
    while (loop.hasNext()) {
        bind dlp = loop.next();
        sizeNow = dlp.size;
        if (sizeNow == bind.FULL) {
            if (cell_open) {
                //close half
                temp_row = newTempHolderBy2();
                ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, calculateRowHeightBy2()));
                cell_open = false;
                halfSizeOnHold = 0;
            }
            ll.addView(newRelativeLayout(dlp, sizeNow));
        } else if (sizeNow == bind.HALF) {
            if (!cell_open) {
                temp_row = newTempHolder();
                cell_open = true;
            }
            halfSizeOnHold++;
            //adding view to layout
            temp_row.addView(newRelativeLayout(dlp, sizeNow));
        }

        if (index == list_configuration.size() - 1 && cell_open || cell_open && halfSizeOnHold >= 3) {
            ll.addView(temp_row, new TableLayout.LayoutParams(screen_size.x, row_height));
            cell_open = false;
            halfSizeOnHold = 0;
        }

        index++;
    }
}