2016-07-19 4 views
0

Я пытаюсь решить эту проблему, но я не нахожу решения, поэтому, пожалуйста, помогите мне решить проблему. 1) Мой Package.java файл:FATAL Исключение: java.lang.RuntimeException: Не удалось запустить активность ComponentInfo

b_indian=(Button)findViewById(R.id.b_indian); 
     b_classic=(Button)findViewById(R.id.b_classic); 
     b_royal=(Button)findViewById(R.id.b_royal); 
     t_pkg=(TextView)findViewById(R.id.t_pkg); 
     t_indian=(TextView)findViewById(R.id.t_indian); 
     t_classic=(TextView)findViewById(R.id.t_classic); 
     t_royal=(TextView)findViewById(R.id.t_royal); 

     b_indian.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Package.this,Indianpkg.class); 
       startActivity(i); 
      } 
     }); 

     b_classic.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Package.this,Classicpkg.class); 
       startActivity(i); 
      } 
     }); 

     b_royal.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Package.this,Royalpkg.class); 
       startActivity(i); 
      } 
     }); 

    } 
} 

2) activity_package.xml

<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text="Package" 
     android:id="@+id/t_pkg" 
     android:layout_gravity="center_horizontal" 
     style="@style/Title"/> 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 


    <TableRow 
     android:layout_width="fill_parent" 
     android:layout_height="0dp" 
     android:weightSum="1" 
     android:layout_weight="0.5"> 

     <RelativeLayout 
      android:layout_width="0dp" 
      android:layout_height="match_parent" 
      android:layout_weight="0.5"> 


     <Button 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:id="@+id/b_indian" 

      android:textSize="18sp" 
      android:gravity="center" 
      android:singleLine="false" 
      android:paddingBottom="10dp" 
      android:layout_margin="25dp"/> 


</RelativeLayout> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:textAppearance="?android:attr/textAppearanceLarge" 
       android:text="INDIAN" 
       android:id="@+id/t_indian" 
       android:layout_margin="55dp" 
       android:gravity="center_horizontal" 
       style="@style/SimpleText"/> 

     </RelativeLayout> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 


       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_classic" 

        android:textSize="18sp" 
        android:gravity="center" 
        android:singleLine="false" 
        android:paddingBottom="10dp" 
        android:layout_margin="25dp" /> 


      </RelativeLayout> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:text="CLASSIC" 
        android:layout_margin="50dp" 
        android:id="@+id/t_classic" 
        android:layout_gravity="center_horizontal" 
        style="@style/SimpleText"/> 

      </RelativeLayout> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 

      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 


       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_royal" 

        android:textSize="18sp" 
        android:gravity="center" 
        android:singleLine="false" 
        android:paddingBottom="10dp" 
        android:layout_margin="25dp"/> 



      </RelativeLayout> 


      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <TextView 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:textAppearance="?android:attr/textAppearanceLarge" 
        android:text="ROYAL" 
        android:layout_margin="55dp" 
        android:id="@+id/t_royal" 
        android:layout_gravity="center_horizontal" 
        style="@style/SimpleText"/> 

      </RelativeLayout> 
     </TableRow> 

    </TableLayout> 

Это мой файл пакета и я поставил тот же код намерению три разных пакета в этом файле, но я намерен только индийский пакет и остальные два пакета не намерены, и у меня есть ошибка: FATAL Exception. После всех файлов: 1) Indianpkg.java

b_i_venue=(Button)findViewById(R.id.b_i_venue); 
     b_i_decor=(Button)findViewById(R.id.b_i_decor); 
     b_i_caterer=(Button)findViewById(R.id.b_i_caterer); 
     b_i_photo=(Button)findViewById(R.id.b_i_photo); 
     b_i_mehandi=(Button)findViewById(R.id.b_i_mehandi); 
     b_i_dj=(Button)findViewById(R.id.b_i_dj); 
     t1=(TextView)findViewById(R.id.t1); 

     b_i_venue.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Indianpkg.this,Indian_venue.class); 
       startActivity(i); 
      } 
     }); 

     b_i_decor.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Indianpkg.this,Indian_decoration.class); 
       startActivity(i); 
      } 
     }); 

     b_i_caterer.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Indianpkg.this,Indian_decoration.class); 
       startActivity(i); 
      } 
     }); 

     b_i_photo.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Indianpkg.this,Indian_caterer.class); 
       startActivity(i); 
      } 
     }); 

     b_i_mehandi.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Indianpkg.this,Indian_mehandi.class); 
       startActivity(i); 
      } 
     }); 

     b_i_dj.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Indianpkg.this,Indian_dj.class); 
       startActivity(i); 
      } 
     }); 


    } 
} 

2) activity_indianpkg.xml

<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text=" Indian Wedding" 
     android:id="@+id/t1" 
     android:layout_gravity="center_horizontal" 
     style="@style/Title"/> 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 

       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_i_venue" 
        android:background="@drawable/i_venue" 
        android:text="Venue" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:singleLine="false" 
        android:paddingBottom="10dp" 
        android:layout_margin="10dp" 
        style="@style/Title"/> 
      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_i_decor" 
        android:background="@drawable/i_decoration" 
        android:text="Decoration" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:singleLine="false" 
        android:paddingBottom="10dp" 
        android:layout_margin="10dp" 
        style="@style/Title"/> 
      </RelativeLayout> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_i_caterer" 
        android:text="Caterer" 
        android:background="@drawable/i_caterer" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:layout_margin="10dp" 
        android:paddingBottom="10dp" 
        style="@style/Title"/> 

      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_i_photo" 
        android:text="Photography" 
        android:background="@drawable/i_photography" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:paddingBottom="10dp" 
        android:layout_margin="10dp" 
        style="@style/Title"/> 
      </RelativeLayout> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_i_mehandi" 
        android:text="Mehandi" 
        android:background="@drawable/i_mahendi" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:layout_margin="10dp" 
        android:paddingBottom="10dp" 
        style="@style/Title"/> 

      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_i_dj" 
        android:text="DJ" 
        android:background="@drawable/i_dj" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:layout_margin="10dp" 
        style="@style/Title" 
        android:paddingBottom="10dp"/> 

      </RelativeLayout> 
     </TableRow> 

    </TableLayout> 

Над кодом выполняется успешно. Но ниже код тоже тот же, но все еще не выполняется и дает FATAL Exception.

3) Classic.java

b_c_venue=(Button)findViewById(R.id.b_i_venue); 
     b_c_decor=(Button)findViewById(R.id.b_i_decor); 
     b_c_caterer=(Button)findViewById(R.id.b_i_caterer); 
     b_c_photo=(Button)findViewById(R.id.b_i_photo); 
     b_c_mehandi=(Button)findViewById(R.id.b_i_mehandi); 
     b_c_dj=(Button)findViewById(R.id.b_i_dj); 
     t2=(TextView)findViewById(R.id.t2); 

     b_c_venue.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Classicpkg.this,Classic_venue.class); 
       startActivity(i); 
      } 
     }); 

     b_c_decor.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Classicpkg.this,Classic_decoration.class); 
       startActivity(i); 
      } 
     }); 

     b_c_caterer.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Classicpkg.this,Classic_caterer.class); 
       startActivity(i); 
      } 
     }); 

     b_c_photo.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Classicpkg.this,Classic_photography.class); 
       startActivity(i); 
      } 
     }); 

     b_c_mehandi.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Classicpkg.this,Classic_mehandi.class); 
       startActivity(i); 
      } 
     }); 

     b_c_dj.setOnClickListener(new View.OnClickListener() { 
      @Override 
      public void onClick(View v) { 
       Intent i=new Intent(Classicpkg.this,Classic_dj.class); 
       startActivity(i); 
      } 
     }); 

    } 
} 

4) activity_classic.xml

<TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceLarge" 
     android:text=" Classic Wedding" 
     android:id="@+id/t2" 
     android:layout_gravity="center_horizontal" 
     style="@style/Title"/> 

    <TableLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent"> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 

       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_c_venue" 
        android:background="@drawable/i_venue" 
        android:text="Venue" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:singleLine="false" 
        android:paddingBottom="10dp" 
        android:layout_margin="10dp" 
        style="@style/Title"/> 
      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_c_decor" 
        android:background="@drawable/i_decoration" 
        android:text="Decoration" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:singleLine="false" 
        android:paddingBottom="10dp" 
        android:layout_margin="10dp" 
        style="@style/Title"/> 
      </RelativeLayout> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_c_caterer" 
        android:text="Caterer" 
        android:background="@drawable/i_caterer" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:layout_margin="10dp" 
        android:paddingBottom="10dp" 
        style="@style/Title"/> 

      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_c_photo" 
        android:text="Photography" 
        android:background="@drawable/i_photography" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:paddingBottom="10dp" 
        android:layout_margin="10dp" 
        style="@style/Title"/> 
      </RelativeLayout> 
     </TableRow> 

     <TableRow 
      android:layout_width="fill_parent" 
      android:layout_height="0dp" 
      android:weightSum="1" 
      android:layout_weight="0.5"> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_c_mehandi" 
        android:text="Mehandi" 
        android:background="@drawable/i_mahendi" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:layout_margin="10dp" 
        android:paddingBottom="10dp" 
        style="@style/Title"/> 

      </RelativeLayout> 
      <RelativeLayout 
       android:layout_width="0dp" 
       android:layout_height="match_parent" 
       android:layout_weight="0.5"> 
       <Button 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" 
        android:id="@+id/b_c_dj" 
        android:text="DJ" 
        android:background="@drawable/i_dj" 
        android:textSize="18sp" 
        android:gravity="center|bottom" 
        android:layout_margin="10dp" 
        style="@style/Title" 
        android:paddingBottom="10dp"/> 

      </RelativeLayout> 
     </TableRow> 

    </TableLayout> 

enter image description here

+0

любезно предоставить LogCat. – UMESH0492

+0

Вы объявляете свою «активность» в файле 'manifest.xml'? – Ironman

+1

Пожалуйста, не публикуйте свой ** весь проект **. Просто опубликуйте важные части файлов. Также самое главное - ошибка logcat. – Vucko

ответ

0

Может быть, вы не добавить класс активности в AndroidMaifest.xml
, если вы этого не сделаете!

Добавить активность в свой AndroidMaifest.xml

как это

 <activity 
      android:name=".Classic" 
      android:label="your_activity_label"> 
     </activity> 

Тогда Редактировать код в Classic.java

b_c_venue=(Button)findViewById(R.id.b_c_venue); 
    b_c_decor=(Button)findViewById(R.id.b_c_decor); 
    b_c_caterer=(Button)findViewById(R.id.b_c_caterer); 
    b_c_photo=(Button)findViewById(R.id.b_c_photo); 
    b_c_mehandi=(Button)findViewById(R.id.b_c_mehandi); 
    b_c_dj=(Button)findViewById(R.id.b_c_dj); 
    t2=(TextView)findViewById(R.id.t2); 
0

Ваши идентификаторы неверны для вашего классического вида, изменения ... я. .. для .... c ... в вашей классической деятельности, например:

b_c_venue=(Button)findViewById(R.id.b_c_venue); 
+0

да .. теперь он работает. – elenaVamp

Смежные вопросы