使得在Android的一个TextView点击 [英] making a textview clickable in android

查看:121
本文介绍了使得在Android的一个TextView点击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提出一个Android应用程序,我有4个textviews即的ProductId,标题,描述,image.I希望当我点击他们中的每一个产品的ID应该是displayed.I有一个Web服务这一点。

web服务的输出是

  VMSC>
<响应code =0的消息=成功/>
 - 
< responsedata>
 - 
< productcategories>
 - 
<产品分类与GT;
< ID> 1< / ID>
<冠军>名人与LT; /标题>
<描述>名人与LT; /描述>
<图像>
        < /图片>
< /产品分类>
 - 
<产品分类与GT;
< ID> 2'; / ID>
<冠军>音乐< /标题>
<描述>音乐< /描述>
<图像>
        < /图片>
< /产品分类>
 - 
<产品分类与GT;
< ID>第3版; / ID>
<冠军>体育LT; /标题>
<描述>体育LT; /描述>
<图像>
        < /图片>
< /产品分类>
 - 
<产品分类与GT;
< ID> 4℃/ ID>
<冠军>时尚< /标题>
<描述>时尚< /描述>
<图像>
        < /图片>
< /产品分类>
 - 
<产品分类与GT;
< ID> 5℃/ ID>
<冠军>宗教与LT; /标题>
<描述>宗教与LT; /描述>
<图像>
        < /图片>
< /产品分类>
 - 
<产品分类与GT;
< ID> 6≤/ ID>
<冠军>其他< /标题>
<描述>其他< /描述>
<图像>
        < /图片>
< /产品分类>
< / productcategories>
< / responsedata>
< / VMSC>
 

在此先感谢 图莎尔

解决方案

 最后TextView的视图=(TextView中)findViewById(R.id.textview1);
view.setOnClickListener(新View.OnClickListener(){

  @覆盖
  公共无效的onClick(视图v){
    //这里要求你的web服务。可能使用的AsyncTask和ProgressDialog的
    //这里显示的结果 - 对话或吐司
  }

});
 

I am making an android application,I have 4 textviews namely ProductId,Title,description,image.I want when i click on each one of them product id should be displayed.I have a webservice for this.

Output of webservice is

vmsc>
<response code="0" message="Success"/>
−
<responsedata>
−
<productcategories>
−
<productcategory>
<id>1</id>
<title>Celebrities</title>
<description>Celebrities</description>
<image>
        </image>
</productcategory>
−
<productcategory>
<id>2</id>
<title>Music</title>
<description>Music</description>
<image>
        </image>
</productcategory>
−
<productcategory>
<id>3</id>
<title>Sports</title>
<description>Sports</description>
<image>
        </image>
</productcategory>
−
<productcategory>
<id>4</id>
<title>Fashion</title>
<description>Fashion</description>
<image>
        </image>
</productcategory>
−
<productcategory>
<id>5</id>
<title>Religion</title>
<description>Religion</description>
<image>
        </image>
</productcategory>
−
<productcategory>
<id>6</id>
<title>Others</title>
<description>Others</description>
<image>
        </image>
</productcategory>
</productcategories>
</responsedata>
</vmsc>

Thanks in advance Tushar

解决方案

final TextView view = (TextView) findViewById(R.id.textview1);
view.setOnClickListener(new View.OnClickListener() {

  @Override
  public void onClick(View v) {
    // request your webservice here. Possible use of AsyncTask and ProgressDialog
    // show the result here - dialog or Toast
  }

};);

这篇关于使得在Android的一个TextView点击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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