2016-07-17 516 views
0

這是第一個屏幕的代碼,並且我已經爲這兩個屏幕使用了所有導入語句。我有一個條件語句,用於檢查editText Boxes或ratingBar是否爲空。我的應用程序說它不幸停止工作(android應用程序)

public class BasicDetails extends AppCompatActivity { 

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

     TextView textClass = (TextView)findViewById(R.id.textClass); 
     TextView textSchool = (TextView)findViewById(R.id.textSchool); 
     TextView textPhoto = (TextView)findViewById(R.id.textPhoto); 
     TextView textabtYear = (TextView)findViewById(R.id.textabtYear); 

     final EditText editClass = (EditText)findViewById(R.id.editClass); 
     final EditText editSchool = (EditText)findViewById(R.id.editSchool); 
     final EditText abtyear = (EditText)findViewById(R.id.abtYear); 

     //Button buttonPhoto = (Button)findViewById(R.id.buttonPhoto); 
     Button buttonBnext = (Button)findViewById(R.id.buttonBnext); 

     buttonBnext.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
       // Performs action on click 
       if ((editClass.getText().length() != 0) && (editSchool.getText().length() != 0) && (abtyear.getText().length() != 0)) { 
        Intent intent = new Intent(BasicDetails.this, PortfolioDetails.class); 
        startActivity(intent); 
        //opens the portfolio details class 

       } else { 
        Toast.makeText(BasicDetails.this, "Please enter all the details!!!", Toast.LENGTH_LONG).show(); 
       } 
      } 
     }); 

    } 
} 

這是下一個屏幕的代碼。所以基本上這需要你從一個屏幕到其他的意圖,但我得到一個錯誤消息對我的模擬器,「我的應用程序(或GoPort)已不幸停止工作」

public class PortfolioDetails extends AppCompatActivity { 

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

     TextView textAchievements = (TextView)findViewById(R.id.textAchievements); 
     TextView textProgress = (TextView)findViewById(R.id.textProgress); 
     TextView textFeedback = (TextView)findViewById(R.id.textFeedback); 

     final EditText editAchievements = (EditText)findViewById(R.id.editAchievements); 
     final EditText editFeedback = (EditText)findViewById(R.id.editFeedback); 

     final RatingBar ratingBar = (RatingBar)findViewById(R.id.ratingBar); 

     Button buttonCnext = (Button)findViewById(R.id.buttonCNext); 

     buttonCnext.setOnClickListener(new View.OnClickListener() { 
      public void onClick(View v) { 
       // Performs action on click 

       if ((editAchievements.getText().length() != 0) && (editFeedback.getText().length() != 0)) { 

        ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() { 
         public void onRatingChanged(RatingBar ratingBar, float rating, 
                boolean fromUser) { 
          // place intent for new activity 

          Intent intent = new Intent(PortfolioDetails.this, SlamDetails.class); 
          startActivity(intent); 
          //opens the portfolio details class 

         } 
        }); 
       } else { 
        Toast.makeText(PortfolioDetails.this, "Please enter all the details!!!", Toast.LENGTH_LONG).show(); 
       } 
      } 
     }); 

    } 
} 

我在日誌中獲得此: The red text is what I feel is an error

+2

你能連接沒有問題的錯誤日誌中,您在logcat中看到 –

+1

閱讀:HTTP:// STAC koverflow.com/questions/23353173/uncomfort-myapp-has-stopped-how-can-i-solve-this –

+0

你能定義你的問題嗎? – Ironman

回答

-1

I actually forgot to add the activity to the intent

是啊,我解決了這個問題....基本上有一個與意圖

+0

也會在您的Manifest文件中添加'SlamDetails',因爲您正在'PortfolioDetails'活動中使用它。否則,你會再次遇到這種情況。 –

+0

是啊謝謝你,我已經做到了.... –

相關問題