Search code examples
androidhtmlimageeclipselinkr.java-file

How to link images in android application?


I am creating an android application. I have added four images each to be given four separate links, now when I am trying to link the images as per the below code, i am getting errors. Please guide me.

ImageView img = (ImageView)findViewById(R.id.ImageView1); 
img.setOnClickListener(new   View.OnClickListener(){ public void onClick(View v){ 
   Intent intent = new Intent(); 
   intent.setAction(Intent.ACTION_VIEW); 
   intent.addCategory(Intent.CATEGORY_BROWSABLE); 
   intent.setData(Uri.parse("ac.com")); 
   startActivity(intent); 
  } 
 })

Solution

  • ImageView img = (ImageView)findViewById(R.id.ImageView1); 
    img.setOnClickListener(new   View.OnClickListener(){ 
    public void onClick(View v){ 
    Intent intent = new Intent(); 
    intent.setAction(Intent.ACTION_VIEW); 
    intent.addCategory(Intent.CATEGORY_BROWSABLE); 
    intent.setData(Uri.parse("https://www.google.com")); 
    startActivity(intent); 
    }
    });
    

    Is it the semi-colon that is missing? Try above code.