2016-06-14 62 views
0

我想要的全部是当我点击文本框上的电子邮件时,它会打开电子邮件或Gmail,当它打开电子邮件或其他应用程序时,它会在地址中写入电子邮件,我知道我需要将textview clickable只是帮助我的代码,如果它是可能和简单的。点击电子邮件图像查看

的Java类:

ImageView ivImageFromUrl; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_second); 
     ivImageFromUrl = (ImageView) findViewById(R.id.iv_image_from_url); 
     Picasso.with(getApplicationContext()).load("http://i67.tinypic.com/20k9n42.jpg").into(ivImageFromUrl); 
     OnClickButtonListener(); 


     TextView numTextView = (TextView) findViewById(R.id.textView8); 
     numTextView.setOnClickListener(new View.OnClickListener() { 

      @Override 
      public void onClick(View v) { 
       Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("tel: 244892501")); 
       startActivity(intent); 
      } 

     }) 

     ; 
    } 

    public void OnClickButtonListener() { 

     button1 = (Button) findViewById(R.id.button1); 
     button1.setOnClickListener(
       new View.OnClickListener() { 
        @Override 
        public void onClick(View v) { 
         Intent intent = new Intent(SecondActivity.this, Contactos.class); 
         startActivity(intent); 
        } 
       } 
     ); 

    } 
} 
+0

您的问题访问不上点击的TextView它打开应用程序的电子邮件,并写上TextView的简单DAT电子邮件明确 –

+0

。 –

+0

哦,我忘了把XML文件,但我有一个图像视图 –

回答

0

设置您的ImageView点击收听。在您的TextView to get the text, then add it to your email intent emailIntent.putExtra(Intent.EXTRA_TEXT, text);上使用getText().toString()。见下文。你需要设置你的TextView作为最终的,因此它可以在onclick

final TextView textView = findViewById(...) 

imageView.setOnClickListener(new View.OnClickListener() { 
    @Override 
    public void onClick(View v) { 
     String text = textView.getText().toString(); 
     Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", emailAddress, null)); 
     emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Subject"); // Whatever subject 
     emailIntent.putExtra(Intent.EXTRA_TEXT, text); 
     context.startActivity(Intent.createChooser(emailIntent, "Send email")); 
    } 
}); 
相关问题