在设计一个布局与android中的textview错误
问题描述:
我正在开发android应用程序,其中我必须做一个布局涉及一个微调和textview.I有problem.that文本视图不clickable.I给了一个背景每个人textview.Can的指导我如何使这个..在设计一个布局与android中的textview错误
下面是截图 http://www.freeimagehosting.net/bc2a1
下面是XML的代码 http://pastebin.com/Y1Dsq4B1
在此先感谢 图沙·萨尼
答
我很确定所有视图都是可点击的。
LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View v = vi.inflate(R.layout.text, null);
TextView t = (TextView) v.findViewById(R.id.lblText);
t.setText(text);
t.setOnClickListener(new OnClickListener(){ public void onClick(View v) {
// do something
}});
return v;
答
首先,您需要更改布局xml中的TextViews的名称,以使它们不完全相同。现在他们都是text_section
。然后你需要在你的活动中添加代码,看起来像每个TextView的波纹管:
TextView selection = (TextView) findViewById(R.id.text_selection); //declares the TextView
selection.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Code to execute when TextView is pressed goes here
}
});
什么错误? – 2011-12-14 05:12:03
[我如何在ListView中执行延迟加载的图像]可能的重复(http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in- listview) – User 2013-07-18 08:28:41