Skip to content Skip to sidebar Skip to footer

Android : Textview Makes App Stop

i have created a CalendarView that whenever you select a date a new activity opens.In that new activity i have put a button and aTextView and I want that TextView to display a stri

Solution 1:

Your layout is

<TextView
    android:id="@+id/textView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Large Text"
    android:textAppearance="?android:attr/textAppearanceLarge" />

and you have : EditText editText=(EditText) this.findViewById(R.id.textView);

We have a ClassCastException here I suppose, as a TextView can't be cast to an EditText, and so your app crashes.

AFAIK, this should be TextView textView=(TextView) this.findViewById(R.id.textView);

Solution 2:

The string "display" you are using might be null.Log the value what you are getting in that string. Also in your code the bundle variable you are using is extraz with a 'z' and trying to read it with extras with a 's'.c d logcat if you are getting nullpointer.

Bundleextraz=getIntent().getExtras();
Stringdisplay= extras.getString("EXTRA_MESSAGE");

Also your xml doesn't have an edit text.check for textview in your activity instead of editext.

Solution 3:

You are typecasting a textview to an edit text in your code. Change EditText to TextView in code other wise it will give a class cast exception

Post a Comment for "Android : Textview Makes App Stop"