I am trying to create app which is match text with appropriate images by 
pointing with line.

I want to create app exactly same which is shown in the below image:

[image: I created List of text views and a grid view of images in between I 
have linear layout. When I click on text view I will get (x1,y1) points of 
text view and when I click on image I will get (x2,y2) positions of image 
view. I am passing this values to Drawing class to draw a line. But every 
time its drawing only one line.]

can any one please give me an idea?

This is my main class:

public class MatchActivity extends Activity {
    ArrayAdapter<String> listadapter;
    float x1;
    float y1;
    float x2;
    float y2;
    ArrayList<Float> points ;
    ArrayList<Float> points1 ;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        String[] s1 = { "smiley1", "smiley2", "smiley3" };

        ListView lv = (ListView) findViewById(R.id.text_list);
        ArrayList<String> list = new ArrayList<String>();
        points = new ArrayList<Float>();
        list.addAll(Arrays.asList(s1));
        listadapter = new ArrayAdapter<String>(this, R.layout.rowtext, s1);
        lv.setAdapter(listadapter);
        GridView gv = (GridView) findViewById(R.id.image_list);
        gv.setAdapter(new ImageAdapter(this));
        lv.setOnItemClickListener(new OnItemClickListener() {
          public void onItemClick(AdapterView<?> arg0, View v, int arg2,long 
arg3){
               points = new ArrayList<Float>();
               x1=v.getX();
               y1=v.getY();
               points.add(Float.valueOf(x1));
               points.add(Float.valueOf(y1));;
               Log.d("list","text positions"+points);
           }
        });

This is my drawing class to draw a line:

public class DrawView extends View {
    Paint paint = new Paint();
  private List<Float> position1=new ArrayList<Float>();
  private List<Float> position2=new ArrayList<Float>();;
    float x1,y1,x2,y2;
    ListView lv;
    GridView gv;
    public DrawView(Context context,ArrayList<Float> points1,ArrayList<Float> 
points2) {
        super(context);
        position1=points1;
        position2=points2;
        invalidate();
        Log.d("drawview","on drawview pos1:"+position1+" pos2:"+position2) ;

    }

    @Override
    public void onDraw(Canvas canvas) {
         super.onDraw(canvas);
         Log.d("on draw","on draw position1:"+position1+" 
position2:"+position2);
         x1=position1.get(0).floatValue();
         y1=position1.get(1).floatValue();
         x2=position2.get(0).floatValue();
         y2=position2.get(1).floatValue();
         paint.setColor(Color.BLACK);
         paint.setStrokeWidth(3);
         canvas.drawLine(x1,y1+75, x2+300,y2, paint);

    }

}

Thanks in advance .

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to