Android 在图像上显示单词或特定字符串

Android 在图像上显示单词或特定字符串,android,image,Android,Image,我正在创建一个应用程序,当我触摸人类时,它会显示不同的部件名称 我的主要活动课程如下 public class VideosActivity extends Activity implements OnTouchListener { //DrawView draw; float a=0; float b=0; ImageView image; MotionEvent event; Button

我正在创建一个应用程序,当我触摸人类时,它会显示不同的部件名称

我的主要活动课程如下

  public class VideosActivity extends Activity implements OnTouchListener {
        //DrawView draw;
        float a=0;
        float b=0;
        ImageView image;
        MotionEvent event;
        Button  back ;
        Button next;
        TextView t;
        String info = "";
        int count =0;
        FirstImage i;
        ViewFlipper c;
        Infoview v;
        String huma="human";
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
             setContentView(R.layout.videos_layout);
             i=new FirstImage(this);
             v=new Infoview(this);
             c=(ViewFlipper) findViewById(R.id.viewFlipper1);
             back = (Button) findViewById(R.id.button1);
             next = (Button) findViewById(R.id.button2);
             t=(TextView) findViewById(R.id.textView1);
             if(count==0)
                i.changeImage(R.drawable.human ); 
             i.invalidate();
             c.addView(i,0);
             c.setOnTouchListener(this);
                c.onTouchEvent(event);
             addListenerOnButton();


    }

 public void pageinfo(float a,float b){

        t.setText(Float.toString(a)+"x"+Float.toString(b)+"y");
        if(i.getSrc()==R.drawable.human){
            v.updateInfo(huma, a, b);
            i.invalidate();
            v.invalidate();
        }
    }



    public boolean onTouch(View v, MotionEvent me) {
        // TODO Auto-generated method stub
        switch(me.getAction()){
        case MotionEvent.ACTION_DOWN:
            a=me.getX();
            b= me.getY();
            pageinfo(a,b);
            break;
        case MotionEvent.ACTION_MOVE:
            a=me.getX();
            b= me.getY();
            pageinfo(a,b);
            break;
        case MotionEvent.ACTION_UP:
            a=me.getX();
            b= me.getY();
            pageinfo(a,b);
            break;
        case MotionEvent.ACTION_OUTSIDE:
            a=me.getX();
            b= me.getY();
            pageinfo(a,b);
            break;
        default: return false;
        }
        return true;

    }
    }
用于在图像上显示文本的另一个类infoView工作不正常

public class Infoview extends View {

 String info = "";
 float x = 0; //init value 
 float y = 0; //init value
 int color = Color.WHITE;

 public Infoview(Context context) {
  super(context);
  // TODO Auto-generated constructor stub
 }

 public Infoview(Context context, AttributeSet attrs) {
  super(context, attrs);
  // TODO Auto-generated constructor stub
 }

 public Infoview(Context context, AttributeSet attrs, int defStyle) {
  super(context, attrs, defStyle);
  // TODO Auto-generated constructor stub
 }

 @Override
 protected void onDraw(Canvas canvas) {
  // TODO Auto-generated method stub
  super.onDraw(canvas);

  Paint paint = new Paint();
  paint.setStyle(Paint.Style.FILL_AND_STROKE);
  paint.setColor(color);
  paint.setStrokeWidth(2);
  paint.setTextSize(30);

  canvas.drawLine(x-10, y, x+10, y, paint);
  canvas.drawLine(x, y-10, x, y+10, paint);
  canvas.drawText(info, x, y, paint);

 }

 public void updateInfo(String t_info, float t_x, float t_y){
  info = t_info;
  x = t_x;
  y = t_y;
  invalidate();
 }

 public void clearInfo(){
  info = "";
  x = 0;
  y = 0;
  invalidate();
 }

}

它没有显示任何输出…

您确定吗?你的背景是黑色的,因为你的绘画也是。如果将其编辑为白色,那么它也不会显示输出。也许你在这里找到了一些东西:也许你在玩,也许你只是在画图像的外部。我正在传递我正在触摸的同一个坐标。