public class SetcolorActivity extends Activity {
/** Called when the activity is first created. */
private TextView tips;
private ImageView img;
private int flag=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tips=(TextView)findViewById(R.id.tips);
img=(ImageView)findViewById(R.id.imageView1);
img.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
switch(event.getAction())
{
case MotionEvent.ACTION_MOVE:
if(flag==0)
{
tips.setText("color is blue");
tips.setTextColor(Color.BLUE);
flag=1;
}
else
{
tips.setText("color is red");
tips.setTextColor(Color.RED);
}
case MotionEvent.ACTION_UP:
tips.setText(" ");
break;
default:
break;
}
return true;
}
});
}
}
/** Called when the activity is first created. */
private TextView tips;
private ImageView img;
private int flag=0;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
tips=(TextView)findViewById(R.id.tips);
img=(ImageView)findViewById(R.id.imageView1);
img.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
// TODO Auto-generated method stub
switch(event.getAction())
{
case MotionEvent.ACTION_MOVE:
if(flag==0)
{
tips.setText("color is blue");
tips.setTextColor(Color.BLUE);
flag=1;
}
else
{
tips.setText("color is red");
tips.setTextColor(Color.RED);
}
case MotionEvent.ACTION_UP:
tips.setText(" ");
break;
default:
break;
}
return true;
}
});
}
}
解决方案 »
- android dialog输入框被遮蔽
- Android距离感应器可以感应多长距离
- 请问一个安卓事件的问题?
- 哪位侠哥给讲讲关于service类里的Binder类。。。
- 调用方法 急。。。
- 应用怎么同时跑在两个模拟器上?
- ListView(android.R.layout.simple_list_item_1)字体过大,要怎么修改?
- 连接google地图,执行都ok,但是说没有安装google play service
- 安卓蓝牙串口接收数据问题
- 百度地图初始化总是日记显示galaxy lib host missing meta-data
- android中如何实现双缓冲铺地图(卡马克算法)
- Android4.0都有哪些变化,知道的都进来说下
case MotionEvent.ACTION_UP:
tips.setText(" ");
你在放开的时候
tips.setText("这里是文本");
在试试就有文本了!