下面列出了android.widget.TableLayout#setTag ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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;
}
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;
}
public void convertListToOrdered(TableLayout _table) {
EditorControl type = editorCore.createTag(EditorType.ol);
_table.setTag(type);
for (int i = 0; i < _table.getChildCount(); i++) {
View _childRow = _table.getChildAt(i);
CustomEditText editText = (CustomEditText) _childRow.findViewById(R.id.txtText);
editText.setTag(editorCore.createTag(EditorType.OL_LI));
_childRow.setTag(editorCore.createTag(EditorType.OL_LI));
TextView _bullet = (TextView) _childRow.findViewById(R.id.lblOrder);
_bullet.setText(String.valueOf(i + 1) + ".");
}
}
public void convertListToUnordered(TableLayout _table) {
EditorControl type = editorCore.createTag(EditorType.ul);
_table.setTag(type);
for (int i = 0; i < _table.getChildCount(); i++) {
View _childRow = _table.getChildAt(i);
CustomEditText _EditText = (CustomEditText) _childRow.findViewById(R.id.txtText);
_EditText.setTag(editorCore.createTag(EditorType.UL_LI));
_childRow.setTag(editorCore.createTag(EditorType.UL_LI));
TextView _bullet = (TextView) _childRow.findViewById(R.id.lblOrder);
_bullet.setText("•");
}
}