Posté(e) 23 février 20224 a Bonjour , aux codeuses et codeurs voici mon code d'erreur que android studio me donne <code>E/AndroidRuntime: FATAL EXCEPTION: main Process: insecte.programme.ulision, PID: 18752 java.lang.RuntimeException: Unable to start activity ComponentInfo{insecte.programme.ulision/insecte.programme.ulision.ui.home.D_Holometabola.Lepidoptera_ORDER.PlaceDetailsActivity}: java.lang.NullPointerException at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3449) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) Caused by: java.lang.NullPointerException at java.util.Objects.requireNonNull(Objects.java:220) at insecte.programme.ulision.ui.home.D_Holometabola.Lepidoptera_ORDER.PlaceDetailsActivity.init(PlaceDetailsActivity.java:63) at insecte.programme.ulision.ui.home.D_Holometabola.Lepidoptera_ORDER.PlaceDetailsActivity.onCreate(PlaceDetailsActivity.java:35) at android.app.Activity.performCreate(Activity.java:8000) at android.app.Activity.performCreate(Activity.java:7984) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1309) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3422) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3601) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:85) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:223) at android.app.ActivityThread.main(ActivityThread.java:7656) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947) I/Process: Sending signal. PID: 18752 SIG: 9 Disconnected from the target VM, address: 'localhost:64015', transport: 'socket'</code> et voici le code mon fichier java.xml <code> public class PlaceDetailsActivity extends AppCompatActivity { private ImageView placeImageView; private TextView placeNameTextView, placeDescriptionTextView, placeCityTextView, placePhoneTextView, placeAddressTextView, placeRatingCountTextView; private LinearLayout phoneLinearLayout; private RatingBar placeRatingBar; private String placeType; private PlaceModel placeModel; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_place_details); init(); setViewsValues(); } @Override public void onBackPressed(){ sendToMain(); } @Override public boolean onOptionsItemSelected(@NonNull MenuItem item) { if (item.getItemId() == android.R.id.home) { sendToMain(); } return super.onOptionsItemSelected(item); } private void sendToMain(){ Intent intent = new Intent(this, Lepidopteres__Deux.class); intent.putExtra("type", placeType); startActivity(intent); finish(); } private void init(){ Gson gson = new Gson(); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle(R.string.details_header); placeImageView = findViewById(R.id.place_imageView); placeNameTextView = findViewById(R.id.placeName_textView); placeDescriptionTextView = findViewById(R.id.placeDesc_textView); placeCityTextView = findViewById(R.id.placeCity_textView); placePhoneTextView = findViewById(R.id.placePhone_textView); placeAddressTextView = findViewById(R.id.placeAddress_textView); phoneLinearLayout = findViewById(R.id.phone_linearLayout); placeRatingBar = findViewById(R.id.place_RatingBar); placeRatingCountTextView = findViewById(R.id.ratingCount_textView); placeType = getIntent().getStringExtra("type"); String placeAsString = getIntent().getStringExtra("placeObj"); placeModel = gson.fromJson(placeAsString, PlaceModel.class); } private void setViewsValues(){ if(placeType.equals("historical")) { phoneLinearLayout.setVisibility(View.GONE); } else { placePhoneTextView.setText(placeModel.getPhone()); } placeImageView.setImageResource(placeModel.getImageResID()); placeNameTextView.setText(placeModel.getName()); placeDescriptionTextView.setText(placeModel.getDescription()); placeCityTextView.setText(placeModel.getCity()); placeAddressTextView.setText(placeModel.getAddress()); placeRatingBar.setRating(placeModel.getRate()); placeRatingCountTextView.setText(String.valueOf(placeModel.getRate())); } }</code> si vous pouvais aider à résoudre mon problème pas à pas afin que je puisse bien résoudre mo problème car je suis gros débutant et très isolé . ce serai cool merci
Posté(e) 24 février 20224 a Auteur j'ai supprimé les lignes // setViewsValues(); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // getSupportActionBar().setTitle(R.string.details_header); l'activité s'ouvre mais vide , comment avoir les données. autre question à la place d'ouvrir une activité et il possible d'ouvrir un fragment à la place et comment dois je procéder . merci
Rejoignez la conversation
Vous pouvez poster maintenant et vous enregistrez plus tard. Si vous avez un compte, connectez-vous maintenant pour poster.