Java Android电子邮件应用程序使用选项卡时发送按钮无响应

Java Android电子邮件应用程序使用选项卡时发送按钮无响应,java,android,Java,Android,这是处理电子邮件的类 public class Email extends Activity implements View.OnClickListener { EditText subject, message; String emailaddress[] = {"myemail@domain.com", "otheremail@other.com"}; String msgSend, subjectSend; Button sendEmail; @Override protected vo

这是处理电子邮件的类

public class Email extends Activity implements View.OnClickListener {
EditText subject, message;
String emailaddress[] = {"myemail@domain.com", "otheremail@other.com"};
String msgSend, subjectSend;
Button sendEmail;

@Override
protected void onCreate(Bundle savedInstanceState) 
{
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.email_view);
    initializeVars();
    sendEmail.setOnClickListener(this);
}

private void initializeVars() 
{
    // TODO Auto-generated method stub
    subject = (EditText) findViewById(R.id.etSubject);
    message = (EditText) findViewById(R.id.etMessage);
    sendEmail = (Button) findViewById(R.id.bSendEmail);
}

public void onClick(View v) 
{
    // TODO Auto-generated method stub
    msgSend = message.getText().toString();
    subjectSend = subject.getText().toString();

    Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
    emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, emailaddress);
    emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subjectSend);
    emailIntent.setType("plain/text");
    emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, msgSend);
    startActivity(emailIntent);
}


@Override
protected void onPause() 
{
    // TODO Auto-generated method stub
    super.onPause();
    finish();
}

谢谢你看我的问题。非常感谢您的帮助。

此处无法访问您的选项卡上下文,请尝试使用getActivity()作为上下文:

case 3:
                emailView.findViewById(R.id.emailView);
                return emailView;

检查,然后讨论上下文。

这解决了我遇到的问题。非常感谢。
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="@+id/emailView" >

<EditText
    android:id="@+id/etSubject"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10" 
    android:hint="@string/subject_hint">

</EditText>

<EditText
    android:id="@+id/etMessage"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:ems="10"
    android:inputType="textMultiLine" 
    android:lines="15"
    android:gravity="top|left"
    android:hint="@string/message_hint"/>

<Button
    android:id="@+id/bSendEmail"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:text="@string/send_email" />
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.packagename"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="17" />

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_shacs_metal"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" 
    >
    <activity
        android:name="com.packagename.Tabs"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="com.packagename.Tabs" />

            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.packagename.Splash"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name="com.packagename.Email"
        android:label="@string/app_name" >
    </activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
case 3:
                emailView.findViewById(R.id.emailView);
                return emailView;
case 3:
    emailView.findViewById(R.id.emailView);
    Class ourClass = Class.forName("com.packagename.Email");
    try
    {
        //change this
        //Intent ourIntent = new Intent(Tabs.this, ourClass);
        //to
        Intent ourIntent = new Intent(getActivity(), ourClass);
        getActivity().startActivity(ourIntent);
    }
    catch(ClassNotFoundException e)
    {
         e.printStackTrace();
    }
    return emailView;