机器人:点击时如何得到一个TextView的ID? [英] android: How to get the ID of a textview when clicked?

查看:105
本文介绍了机器人:点击时如何得到一个TextView的ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个从sqllite查询活动并显示输出到XML

I have an activity that queries from sqllite and display the output to xml

这是该活动的一部分

( (TextView) view.findViewById(R.id.tv_id) ).setText( listItem.getId()+"");
( (TextView) view.findViewById(R.id.tv_name) ).setText( listItem.getName() );
( (TextView) view.findViewById(R.id.tv_age) ).setText( listItem.getAge()+"" );

这就是XML:

<TableLayout 
  android:layout_width="wrap_content" 
  android:id="@+id/TableLayout01" 
  android:layout_below="@+id/tv_age" 
  android:layout_height="wrap_content" 
  android:layout_toRightOf="@+id/tv_name">
  <TableRow 
   android:layout_width="wrap_content" 
   android:layout_below="@+id/tv_age" 
   android:layout_height="wrap_content" 
   android:layout_toRightOf="@+id/TableLayout01"   
   android:id="@+id/TableRow01">
   <TextView 
    android:layout_width="10dip" 
    android:layout_height="30dip"     
    android:id="@+id/tv_id" 
    android:text=""     
    android:layout_centerVertical="true">
   </TextView>
   <TextView 
    android:layout_width="100dip" 
    android:layout_height="wrap_content" 
    android:text="" android:id="@+id/tv_name" 
    android:layout_centerVertical="true" 
    android:layout_toRightOf="@+id/tv_id" 
    android:layout_marginLeft="10px">
   </TextView>
   <TextView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="" android:id="@+id/tv_age" 
    android:layout_centerVertical="true" 
    android:layout_toRightOf="@+id/tv_name" 
    android:layout_marginLeft="10px">
   </TextView>
  </TableRow>
 </TableLayout>

现在这工作正常。它显示生成的查询。现在,我想创建显示查询时,这是为了响应长preSS或只需轻轻一按另一个活动。我怎样才能获得pressed的TextView的ID,所以我可以将其用于其他活动?

Now this works fine. It displays the resulting query. Now, I want to create another activity which responds to the long press or just one touch when the query is displayed. How can I get the ID of the pressed textview so I can use it for the other activity?

您的帮助非常感谢。

推荐答案

是不是view.getId()?

isn't it view.getId() ?

这篇关于机器人:点击时如何得到一个TextView的ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆