Reputation: 119
12-01 00:36:28.058: E/AndroidRuntime(5062): Caused by: java.lang.ClassCastException: android.widget.TextView cannot be cast to android.widget.EditText
I am getting above error if anyone knows then tell me ...i shall very thankful
Java:
Log.d("Textra", title);
Log.d("Dextra", des);
EditText t=(EditText) findViewById(R.id.t);
EditText d=(EditText) findViewById(R.id.des);
t.setText(title);
d.setText(des);
XML:
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/t"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/des"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""/>
</LinearLayout>
Upvotes: 8
Views: 22021
Reputation: 8929
If there is a cleanup issue then it can throw any casting error.I got this:
Caused by: java.lang.ClassCastException: android.widget.EditText cannot be cast to android.widget.LinearLayout
In eclipse, Just go to Project > Clean & Select your project to clean it.
Upvotes: 1
Reputation: 1
You use textview in xml, but in the activity you try to EditText t=(EditText) findViewById(R.id.t) - not correct; use TextView t=(TextView) findViewById(R.id.t);
or change in xml TextView to EditText
Upvotes: 0
Reputation: 1547
I could solve it by just cleaning the project with project/clean.
Upvotes: 4
Reputation: 86948
<TextView android:id="@+id/t" ... />
<TextView android:id="@+id/des" ... />
EditText t=(EditText) findViewById(R.id.t);
EditText d=(EditText) findViewById(R.id.des);
Do you want TextViews or EditTexts?
Either change the XML to use EditTexts or the Java to use TextViews...
Upvotes: 6