我写了这样的事情....如何在动态生成的表格中获取文本视图的文本?
TableRow tr1;
TableRow tr2;
TextView txt9;
...
TableLayout tl = (TableLayout)findViewById(R.id.myTableLayout);
Display display = getWindowManager().getDefaultDisplay();
int width = display.getWidth();
LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(width, LayoutParams.FILL_PARENT);
for (int i = 0; i < strarr.length-1; i++)
{
strinarr = fun1.split(strarr[i].trim(),"^");
tr1 = (TableRow) new TableRow(this);
txt1=new TextView(this);
txt9.setText(strinarr[0]);
txt9.setBackgroundColor(intblue);
txt9.setTextColor(intwhite);
txt9.setClickable(true);
txt9.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v)
{
Log.i("pagename",strpagename);
String currenttext = txt9.getText().toString());
}
}
});
tr1.addView(txt9);
tl.addView(tr1,new TableLayout.LayoutParams(layoutParams));
}
我能够获得点击的文本,但愚蠢的事情是,我对所有的TextView的单击事件让在表格最后的TextView的文本。 ..如果有人可以告诉我如何抓住textview文本的焦点或触摸它将是真正的帮助完整...
你是酷男人thanx ...很多... – Sourabh 2011-04-04 11:02:51
Thnx很多人。你救了我的一天:) – Dray 2013-02-28 06:30:17