点击后的Android TextView中消失 [英] Android textView disappears when clicked
问题描述
我用android一个TextView:onclick属性。点击后,TextView的消失。我不想当点击TextView的消失。任何想法?
I have a TextView with the android:onClick attribute. When clicked, the TextView disappears. I don't want the TextView to disappear when clicked. Any ideas?
编辑:
<TextView android:id="@+id/textView1"android:text="Click Me!"
android:layout_width="wrap_content"
android:layout_height="wrap_content" android:onClick="processClick"
android:clickable="true"/>
http://i1179.photobucket.com/albums/x386/jenningsr2006/ unclicked.png
http://i1179.photobucket.com/albums/x386/jenningsr2006/ clicked.png
修改
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.example);
TextView t = (TextView)findViewById(R.id.textView1111);
t.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// Do some job here
Toast.makeText(getApplicationContext(), "Clicked", Toast.LENGTH_SHORT).show();
}
});
点击它的操作正确,这不是问题。当我鼠标按下关于TextView的,消失,然后又重新出现在鼠标松开。
Clicking it does the operation correctly, that's not the problem. When I "mousedown" on the TextView, it disappears, then reappears on "mouseup".
推荐答案
我觉得我有同样的问题,但事实证明TextView的不dissapearing,而颜色发生了变化,使这是一样的背景颜色。因此,它似乎隐藏的,但它确实在那里。您可以通过设置设置文本视图点击颜色它的颜色状态列表资源
I thought I had the same problem but it turned out the textview was not dissapearing, rather the color was changing so that it was the same as the background color. Thus it appeared hidden but it really was there. You can set the clicked color of the text view by setting it's color state list resource
http://developer.android.com/guide/主题/资源/颜色列表的resource.html
这篇关于点击后的Android TextView中消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!