2016-02-28 89 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我不能做到这一点! –