2016-02-28 86 views
-1

我已創建登錄。 後,我創建的視圖片列表,每一個工作正常 當我嘗試在它墜毀簽署。從正常活動試圖意圖碎片,並在活動和註冊崩潰

這裏是錯誤:爲Java法

package com.example.asro9.englishcapsules3; 

import android.app.Activity; 
import android.content.Intent; 
import android.os.Bundle; 
import android.view.View; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast; 

/** 
* Created by asro9 on 2/20/2016. 
*/ 
public class SignUPActivity extends Activity 
{ 
    EditText editTextFirstName,editTextSecondName,editTextLastName,editTextPhoneNumber,editTextAddress, 
      editTextUserName,editTextPassword,editTextConfirmPassword;; 
    Button btnCreateAccount; 

    LoginDataBaseAdapter loginDataBaseAdapter; 
    @Override 
    protected void onCreate(Bundle savedInstanceState) 
    { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.signup); 

     // get Instance of Database Adapter 
     loginDataBaseAdapter=new LoginDataBaseAdapter(this); 
     loginDataBaseAdapter=loginDataBaseAdapter.open(); 

     // Get Refferences of Views 
     editTextUserName=(EditText)findViewById(R.id.editTextUserName); 
     editTextPassword=(EditText)findViewById(R.id.editTextPassword); 
     editTextConfirmPassword=(EditText)findViewById(R.id.editTextConfirmPassword); 
     editTextFirstName=(EditText)findViewById(R.id.FirstName); 
     editTextSecondName=(EditText)findViewById(R.id.SecondName); 
     editTextLastName=(EditText)findViewById(R.id.LastName); 
     editTextPhoneNumber=(EditText)findViewById(R.id.PhoneNumber); 
     editTextAddress=(EditText)findViewById(R.id.Address); 

     btnCreateAccount = (Button) findViewById(R.id.buttonCreateAccount); 
     btnCreateAccount.setOnClickListener(new View.OnClickListener() { 

      public void onClick(View v) { 
       // TODO Auto-generated method stub 

       String Firstname = editTextFirstName.getText().toString(); 
       String SeconedName = editTextSecondName.getText().toString(); 
       String LastName = editTextLastName.getText().toString(); 
       String Phone = editTextPhoneNumber.getText().toString(); 
       String Address = editTextAddress.getText().toString(); 
       String userName=editTextUserName.getText().toString(); 
       String password=editTextPassword.getText().toString(); 
       String confirmPassword=editTextConfirmPassword.getText().toString(); 

       // check if any of the fields are vaccant 
       if (userName.equals("")||password.equals("")|| confirmPassword.equals("") || Firstname.equals("") || SeconedName.equals("") || LastName.equals("") || Phone.equals("") || Address.equals("")) { 
        Toast.makeText(getApplicationContext(), "Field Vaccant", Toast.LENGTH_LONG).show(); 
        return; 
       } 
       // check if both password matches 
       if(!password.equals(confirmPassword)) 
       { 
        Toast.makeText(getApplicationContext(), "Password does not match", Toast.LENGTH_LONG).show(); 
        return; 
       } 
       else 
       { 
        // Save the Data in Database 
        loginDataBaseAdapter.insertEntry(userName, password); 
        Toast.makeText(getApplicationContext(), "Account Successfully Created ", Toast.LENGTH_LONG).show(); 
        Intent intent = new Intent(SignUPActivity.this,Fragment1.class); 
        startActivity(intent); 
       } 
      } 
     }); 
    } 
    @Override 
    protected void onDestroy() { 
     // TODO Auto-generated method stub 
     super.onDestroy(); 

     loginDataBaseAdapter.close(); 
    } 
} 

片段

02-28 09:27:55.969 1662-1675/com.example.asro9.englishcapsules3 E/Surface﹕ getSlotFromBufferLocked: unknown buffer: 0xee979760 
02-28 09:28:27.532 1662-1662/com.example.asro9.englishcapsules3 D/AndroidRuntime﹕ Shutting down VM 
02-28 09:28:27.532 1662-1662/com.example.asro9.englishcapsules3 E/AndroidRuntime﹕ FATAL EXCEPTION: main 
    Process: com.example.asro9.englishcapsules3, PID: 1662 
    android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.asro9.englishcapsules3/com.example.asro9.englishcapsules3.Fragment1}; have you declared this activity in your AndroidManifest.xml? 
      at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1794) 
      at android.app.Instrumentation.execStartActivity(Instrumentation.java:1512) 
      at android.app.Activity.startActivityForResult(Activity.java:3917) 
      at android.app.Activity.startActivityForResult(Activity.java:3877) 
      at android.app.Activity.startActivity(Activity.java:4200) 
      at android.app.Activity.startActivity(Activity.java:4168) 
      at com.example.asro9.englishcapsules3.SignUPActivity$1.onClick(SignUPActivity.java:73) 
      at android.view.View.performClick(View.java:5198) 
      at android.view.View$PerformClick.run(View.java:21147) 
      at android.os.Handler.handleCallback(Handler.java:739) 
      at android.os.Handler.dispatchMessage(Handler.java:95) 
      at android.os.Looper.loop(Looper.java:148) 
      at android.app.ActivityThread.main(ActivityThread.java:5417) 
      at java.lang.reflect.Method.invoke(Native Method) 
      at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 

會員註冊代碼,我想導航到:

package com.example.asro9.englishcapsules3;/** 
* Created by NgocTri on 10/18/2015. 
*/ 

import android.app.Fragment; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 
import android.widget.ArrayAdapter; 
import android.widget.ListView; 

import java.util.ArrayList; 

public class Fragment1 extends Fragment { 

    ListView myList; 
    ArrayList<String> Title = new ArrayList<String>(); 
    ArrayAdapter<String> myAdapter; 
    ArrayList<Integer> images = new ArrayList<Integer>(); 
    LazyAdapter myLazyAdapter; 
    LazyAdapter myLazyTitle; 

    public Fragment1() { 
    } 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
     View rootView = inflater.inflate(R.layout.fragment1, container, false); 

     myList = (ListView) rootView.findViewById(R.id.listView); 

     Title.add("Amer At English Capsules"); 
     Title.add("El Fayoum Trip From Capsules"); 
     Title.add("Bla bla bla"); 
     Title.add("Title"); 
     Title.add("Title"); 

     images.add(R.drawable.fen); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.sdsd); 
     images.add(R.drawable.speaking); 
     images.add(R.drawable.fen); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.sdsd); 
     images.add(R.drawable.speaking); 
     images.add(R.drawable.fen); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.sdsd); 
     images.add(R.drawable.speaking); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.cover); 
     images.add(R.drawable.cover); 


     myLazyAdapter = new LazyAdapter(getActivity(),images); 
     myList.setAdapter(myLazyAdapter); 

     return rootView; 

    } 
} 

回答

0

您正在嘗試切換這樣的片段:

Intent intent = new Intent(SignUPActivity.this,Fragment1.class); 
startActivity(intent); 

這是不正確的,因爲片段1不是一個activitiy所以這是提高你報告的錯誤:

android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.asro9.englishcapsules3/com.example.asro9.englishcapsules3.Fragment1}; have you declared this activity in your AndroidManifest.xml? 

我建議看看herehere檢查一些片段原則。

如果你的目標是一旦用戶成功登錄,然後就沒有必要啓動一個新的活動,但執行片段開關切換片段。但是,您也可以採用第二種方法並開始新的活動。但那取決於你。

+0

它是一個應用程序,並在使用後登錄它轉到幻燈片菜單,並切換到主activites我得到用於滑動菜單frgament 1,片段2,用於滑動菜單活動比較,並在符號片段3,用符號和片段1上的視圖的自定義列表工作正常,沒有幻燈片菜單時,當我嘗試所有它出現之間的海市蜃樓,當我試圖拖延清單上的片段​​activites我不能做到這一點! –