我获取从一个数据库中的数据,我追加到一个TextView。当我做长按上的TextView我想将其转换为一个EditText。 这是我的设置数据我TextView的:
I am fetching the data from a database and I am appending it to a TextView. When I do long click on TextView I want to convert it to an EditText. This is how I set the data on my TextView:
TextView text = (TextView) vi.findViewById(R.id.menutext);
text.setText(itemnames[position]);//comes from database append to text view
现在我要定义一个setOnLongClickListener将其转换成的EditText。
Now I want to define a setOnLongClickListener to convert it into a EditText.
text.setOnLongClickListener(new OnLongClickListener() {
public boolean onLongClick(View v) {
String edititemname=itemnames[position];
System.out.println(edititemname);
return true;
}
});
edititemname
持有该项目是pssed在长按$ P $。我想填补了相同的信息到EdiText。请帮我。
edititemname
holds which item was pressed in a long click. I want to fill the same information into the EdiText. Please help me.
据我知道你不能转换一个到另一个。什么,你可以是:有一个TextView和XML创建一个EditText。 TextView的时候是显示的EditText是隐藏的。然后,在你的听众的onclick,您可以:
As far as I know you can't convert one to another. What you can is: Have a TextView and an EditText created in xml. EditText is hidden when TextView is showing. Then, on your listener to the onCLick you can:
text.setVisibility(View.GONE);
editText.setVisibility(View.VISIBLE);
editText.setText(edititemname);
该EDITTEXT变量可以被定义在其中定义文本。你必须使用 findViewById
。
上一篇:MediaPlayer的,进度进度、MediaPlayer
下一篇:TabWidget裹着HorizontalScrollView不与ViewPager滚动不与、裹着、TabWidget、Horizo