android.widget.TableLayout.findViewWithTag()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(1.6k)|赞(0)|评价(0)|浏览(87)

本文整理了Java中android.widget.TableLayout.findViewWithTag()方法的一些代码示例,展示了TableLayout.findViewWithTag()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TableLayout.findViewWithTag()方法的具体详情如下:
包路径:android.widget.TableLayout
类名称:TableLayout
方法名:findViewWithTag

TableLayout.findViewWithTag介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

TableRow inflateRow = (TableRow) View.inflate(Activity, R.layout.table_row, null);

//Main TableLayout

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

for (int i=0;i<10;i++){

  inflate = (TableRow) View.inflate(myActivity, R.layout.table_row, null);
  //set tag for each TableRow
  inflate.setTag(i);
  //add TableRows to TableLayout
  tblAddLayout.addView(inflate);
  //set click listener for all TableRows
  inflateRow.setOnClickListener(this);
}

public void onClick(View v){

  String strTag = v.getTag().toString();
// Find the corresponding TableRow from the Main TableLayout using the tag when you click.

  TableRow tempTableRow = (TableRow)tblAddLayout.findViewWithTag(strTag); 
  //then add your layout in this TableRow tempTableRow.
}

代码示例来源:origin: haibuzou/ExpandTable

@Override
  public void onClick(View v) {
    String tempTag = (String) v.getTag();
    if (rel == null) {
      rel = (RelativeLayout) tableLayout.findViewWithTag(tag);
      expand(rel, position);
      view.isDraw(true);
    } else {
      if (rel.getVisibility() == View.VISIBLE) {
        collapse(rel);
        view.isDraw(false);
      } else {
        if (tempTag.equals(clickPosition)) {
          expand(rel, position);
        }
        view.isDraw(true);
      }
      if (!tempTag.equals(clickPosition)) {
        rel = (RelativeLayout) tableLayout.findViewWithTag(tag);
        expand(rel, position);
        // 上一次的箭头去除
        clicktxt.isDraw(false);
        view.isDraw(true);
      }
    }
    clickPosition = tempTag;
    clicktxt = view;
  }
}

相关文章