2016-06-14 10 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

あなたの質問にアクセスできるようにあなたはそれがアプリの電子メールを開いて、DATなどのTextView簡単な上にある電子メールを書きクリックのTextViewに –

+0

明らかではないが、最終的としてあなたのTextViewを設定する必要があります。 –

+0

ああ、私はxmlファイルを置くのを忘れていたが、私は画像ビューを持っている –

答えて

0

はあなたのImageViewの上でクリックしてリスナーを設定します。 TextView to get the text, then add it to your email intent emailIntent.putExtra(Intent.EXTRA_TEXT, text);getText().toString()を使用してください。下記参照。それは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")); 
    } 
}); 
関連する問題