为什么点击事件没有发生在表格行?

时间:2011-02-11 12:01:15

标签: android-widget android-layout

以编程方式创建tablelayout并向其中添加行。但是,当我点击表格行时,它没有被点击。

在每一行中我都添加了textview和Imageview。我已将onclickListener设置为tablelayout。

TextView txt = (TextView) row.getChildAt(0);
String stTitle = txt.getText().toString();
int index = strTitle.indexOf(stTitle);
Log.d("AllFeat", " index "+index);
Log.d("AllFeat", " title "+stTitle);
int id  = nId.get(index); 
Intent i = new Intent(CatalogPage.this,AllFeats.class); 
i.putExtra("id", id);
i.putExtra("title",stTitle);
startActivity(i);

我在tablelayout.setOnclickListener中编写的上述代码。

1 个答案:

答案 0 :(得分:0)

首先你可以使用setId(nt)设置rowId。调用setcontentview(view).findViewById和setOnclickListener();