我使用数据(字符串)填充TableLayout(即行和列)。访问TableLayout中的内容
当我点击一个单元格时,我希望存储在这个单元格中的数据显示在我的控制台中。
我该怎么做?除了通过身份证以外还有其他方法吗?
我使用数据(字符串)填充TableLayout(即行和列)。访问TableLayout中的内容
当我点击一个单元格时,我希望存储在这个单元格中的数据显示在我的控制台中。
我该怎么做?除了通过身份证以外还有其他方法吗?
如http://developer.android.com/resources/tutorials/views/hello-tablelayout.html所述,android中没有Column或TD(Table Data)或Cell等价物。除非另有说明,否则每个元素都被视为单个单元格。
在我的这个里面,并且你没有在你的行中指定你正在使用什么样的视图,我想这是一个Button,你当然可以点击这样的东西:
Button b = (Button)findViewById(R.id.oneOfMyButtons); // You could create this "on the go"
b.setOnClickListener(new View.OnClickListener{
public void onClick(View v){
System.out.println(v.getText());
}
}
希望这会有所帮助。
虽然我没有使用按钮,但TextViews,感谢您的帮助,我想出了如何从数据中获取数据。非常感谢你! – deimos1988 2011-04-25 01:00:06
TableLayout
延伸LinearLayout
,它没有OnItemClickListener
方法。您需要在子女View
s中实施OnClickListener
。
你可以做的反而是使用GridView
,实现AdapterView
,因此你可以使用OnItemClickListener
http://developer.android.com/resources/tutorials/views/hello-gridview.html
abstract void onItemClick(AdapterView<?> parent, View view, int position, long id)
回调方法被调用时点击此AdapterView中的项目。
非常感谢您的回答,但我尝试过使用GridView,但是这并不是我需要的应用程序。 – deimos1988 2011-04-25 00:58:33
这个问题到底是什么?苹果手机?航天飞机? – 2011-04-24 23:44:47
什么语言/环境? – ariel 2011-04-24 23:44:59
对不起,这是关于Android的开发 – deimos1988 2011-04-25 00:06:12