2012-04-19 14 views
-1

ユーザーがページに入ったことを認証した後、認証を使用してページに入力しています。私はonbackpressed()のコードを書いたが、うまくいきません。ここで、DatabaseDemoとLoginは2つのクラスです。戻るボタンを押すと、ユーザー名とパスワードを持つログインクラスが表示されます。あなたはそれがクラッシュしていますので、もしそれが、押された背中にログインを開始する必要がonbackpressed()メソッドがクラッシュする

public class DatabaseDemo extends TabActivity { 
    DatabaseHelper dbHelper; 
    GridView grid; 
    TextView txtTest; 
    /** Called when the activity is first created. */ 
    @Override 
    public void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.main); 
     SetupTabs(); 
    } 

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) 
    { 
     menu.add(1, 1, 1, "Add Employee"); 
     return true; 
    } 
    public boolean onOptionsItemSelected(MenuItem item) 
    { 
     switch (item.getItemId()) 
     { 
     //Add employee 
     case 1: 
      Intent addIntent=new Intent(this,AddEmployee.class); 
      startActivity(addIntent); 
      break; 
     } 
     super.onOptionsItemSelected(item); 
     return false; 
    } 
    void SetupTabs() 
    { 
     TabHost host=getTabHost(); 
     TabHost.TabSpec spec=host.newTabSpec("tag1"); 
     Intent in1=new Intent(this, AddEmployee.class); 
     spec.setIndicator("Add Employee"); 
     spec.setContent(in1); 

     TabHost.TabSpec spec2=host.newTabSpec("tag2"); 
     Intent in2=new Intent(this, GridList.class); 

     spec2.setIndicator("Employees"); 
     spec2.setContent(in2); 

     host.addTab(spec); 
     host.addTab(spec2); 
    } 
    @Override 
    public void onBackPressed() 
    { 
     Intent i = new Intent(DatabaseDemo.this, Login.class); 
     startActivity(i); 
    } 
} 
+2

あなたが得ているエラーを知るためにlogcat出力を投稿してください。 –

答えて

0

は、その後、おそらくより多くのではなく、ここでのログインアクティビティと間違って何かがあります。

関連する問題