我在项目的mainActivity中使用了一个cusom对话框...它完全正常工作,但是,当我尝试使用该类时,我收到了一条错误消息。
错误是这样的:
The method onCreate(bundle) of type MainActivity must override or implement a supertype method
代码在下面给出......有谁知道问题?请帮帮我......
package MainPRJ.Diary;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.PasswordAuthentication;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import android.R.string;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.provider.Contacts.Settings;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
//This means the baseline (MDPI) asset is 48x48 px, and the high density (HDPI) asset should be 1.5x the baseline at 72x72 px, and the x-high density (XHDPI) asset should be 2x the baseline at 96x96 px, and so on.
public class MainPRJ extends Activity {
/** Called when the activity is first created. */
EditText e1;
ImageView ok,t5,t6;
DBManager dbManager;
Context cont=this;
ArrayList<Object> arl=null;
Boolean f;
int flag=0;
String str;
settings st;
boolean checkcontent;
connectionDetector cd;
Boolean isInternetPresent = false;
static Integer c=3;
/*ArrayList<Object> arrHint;
Context context=this;
ArrayList< Object> arPswd;*/
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
st=new settings();
t5=(ImageView) findViewById(R.id.text5);
t6=(ImageView) findViewById(R.id.text6);
e1=(EditText) findViewById(R.id.editText1);
ok=(ImageView) findViewById(R.id.login_ok);
dbManager=new DBManager(this);
cd = new connectionDetector(getApplicationContext());
checkcontent=dbManager.getavailability();
if(checkcontent)
{
t5.setImageResource(R.drawable.userdetail);
t6.setVisibility(View.VISIBLE);
e1.setVisibility(View.VISIBLE);
ok.setVisibility(View.VISIBLE);
flag=1;
//t5.setEnabled(false);
}
else
{
t6.setVisibility(View.INVISIBLE);
e1.setVisibility(View.INVISIBLE);
ok.setVisibility(View.INVISIBLE);
}
ok.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(e1.getText().toString().equals(""))
{
Toast.makeText(getApplicationContext(), "Enter the password", 5000).show();
}
else
{
arl=dbManager.retrievePswdAsArray();
if(e1.getText().toString().equals((String)arl.get(0)))
{
Intent i1=new Intent(getApplicationContext(), first_page.class);
startActivity(i1);
arl.clear();
}
else
{
Toast.makeText(getApplicationContext(), "Password Incorrect", 5000).show();
}
}
//Toast.makeText(getApplicationContext(), (String)arl.get(0), 3000).show();
}
});
t5.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
//checkcontent=dbManager.getavailability();
//if(checkcontent)
if(flag==1)
{
//t5.setText("User Details");
Intent int3=new Intent(getApplicationContext(), userinfoshow.class);
startActivity(int3);
//t5.setEnabled(false);
}
else
{
Intent int2=new Intent(getApplicationContext(), user_information.class);
startActivity(int2);
}
}
});
t6.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
isInternetPresent = cd.isConnectingToInternet();
arl= dbManager.retrievePswdAsArray();
final String pass=(String)arl.get(0);
arl.clear();
arl=dbManager.retrieveHintAsArray();
final String hint=(String)arl.get(0);
arl.clear();
final Dialog mdialog = new Dialog(MainPRJ.this);
mdialog.setContentView(R.layout.forgot_pswd_dialog);
mdialog.setCanceledOnTouchOutside(true);
final ViewHolder holder = new ViewHolder();
mdialog.setTitle("Password Access");
holder.OK = (Button) mdialog.findViewById(R.id.frgtOk);
holder.CANCEL= (Button) mdialog.findViewById(R.id.frgtCancel);
holder.HINT_ANS = (EditText) mdialog.findViewById(R.id.frgtHint);
holder.CAUTION = (TextView) mdialog.findViewById(R.id.frgtCaution);
mdialog.show();
holder.OK.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(holder.HINT_ANS.getText().toString().equalsIgnoreCase(hint))
{
Toast.makeText(getApplicationContext(), hint+" "+pass, 3000).show();
if (isInternetPresent)
{
ArrayList< Object> arrEmail= dbManager.retrieveDetailsAsArray();
String name=(String)arrEmail.get(0);
final String mail = (String) arrEmail.get(6);
final String content = "Hai "+name+"\n Your security password is : "+pass+"\n\n\n\n\n Regards...AuFriDis";
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try
{
sendMail(mail, content);
}
catch (Exception e) {
// TODO: handle exception
}
}
});
t.start();
mdialog.dismiss();
}
else
{
showAlertDialog(MainPRJ.this, "No Internet Connection",
"Password cannot be sent to mail address...", false);
}
}
else
{
c--;
if(c>0)
{
holder.CAUTION.setText("Incorrect Hint Answer \n"+c+" more try...");
}
else if(c==0)
{
if (isInternetPresent)
{
Toast.makeText(getApplicationContext(), "Your hint answer is send to mail address", 3000).show();
ArrayList< Object> arrEmail= dbManager.retrieveDetailsAsArray();
String name=(String)arrEmail.get(0);
final String mail = (String) arrEmail.get(6);
arrEmail.clear();
arrEmail=dbManager.retrieveHintAsArray();
String hint=(String)arrEmail.get(0);
final String content = "Hai "+name+"\n Your security question is : Nickname of your childhood friend\n Your security answer is : "+hint+"\n\n\n\n\n Regards...AuFriDis";
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try
{
sendMail(mail, content);
}
catch (Exception e) {
// TODO: handle exception
}
}
});
t.start();
c=3;
mdialog.dismiss();
}
else
{
showAlertDialog(MainPRJ.this, "No Internet Connection",
"Security Answer cannot be sent to mail address...", false);
}
}
}
}
});
holder.HINT_ANS.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
holder.CAUTION.setText("");
}
});
holder.CANCEL.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
mdialog.dismiss();
}
});
}
});
}
提前致谢..
答案 0 :(得分:1)
您的项目的java版本可能会以某种方式更改为1.5。尝试将其更改为1.6。
转到
Properties -> JDK Compiler -> Select "1.6" from the Compiler compliance level dropdown (Android only supports 1.5 and 1.6, it does not yet support 1.7)
答案 1 :(得分:0)
报告的错误是指“ MainActivity ”,它在哪里?您已发布课程 MainPRJ 的代码。
此外(虽然不对错误负责)包名称应为小写,例如: com.yourname.yourproject。